Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
pram
Jun 10, 2001

MeruFM posted:

requirejs is when you have a bunch of scripts loaded on a website and you want to guarantee your own poo poo will be run after whatever library

browserify uses node's require("blah") import style and 'compiles' the javascript into a single file

this looks neat but the bower libs i use arent commonjs and using the browserify and vinyl plugins for gulp doesnt seem to be working right

cant wait for es6 modules because holy poo poo this nodejs rabbit hole is complete poo poo

Adbot
ADBOT LOVES YOU

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

pointsofdata posted:

Is there something like linq in c++?

the STL is sort-of like linq but it doesn't quite work the same way. it still has all the same general functions though, has had since c++03, but it wasn't until lambdas showed up in c++11 that it started feeling like linq.

Valeyard
Mar 30, 2012


Grimey Drawer

pram posted:

this looks neat but the bower libs i use arent commonjs and using the browserify and vinyl plugins for gulp doesnt seem to be working right

cant wait for es6 modules because holy poo poo this nodejs rabbit hole is complete poo poo

if there was a flowchart, of all those different systems for dependancy management in js, every single one would end with "combine all files into single file", it seems

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
iterators are kind of like IEnumerables but they have their own set of concepts. you can do really interesting things with them though, like you can write a function that wants to insert items into a container and then you can pass it an insertion iterator that has its own ideas about how items actually go into the container

pram
Jun 10, 2001
the hosed up thing is there apparently used to be a browserify-gulp plugin that would automatically do all this stuff, but npm blacklisted it? lmao. too useful i guess

https://www.npmjs.com/package/gulp-browserify

MeruFM
Jul 27, 2010

pram posted:

this looks neat but the bower libs i use arent commonjs and using the browserify and vinyl plugins for gulp doesnt seem to be working right

cant wait for es6 modules because holy poo poo this nodejs rabbit hole is complete poo poo

I had the same problem so I googled around and came up with this monstrocity for package.json

code:
{
  "name": "poop",
  "version": "0.0.1",
  "devDependencies": {
    "browser-sync": "^1.8.1",
    "browserify": "^3.41.0",
    "browserify-shim": "^3.8.3",
    "del": "^1.1.1",
    "fastclick": "^1.0.6",
    "gulp": "^3.8.11",
    "gulp-browserify": "^0.5.0",
    "gulp-flatten": "0.0.4",
    "gulp-imagemin": "^2.2.1",
    "gulp-jade": "^1.0.0",
    "gulp-load-plugins": "^0.5.1",
    "gulp-minify-css": "^1.0.0",
    "gulp-plumber": "^0.6.2",
    "gulp-rename": "^1.2.0",
    "gulp-rev": "^3.0.1",
    "gulp-rev-replace": "^0.4.0",
    "gulp-sass": "^1.3.3",
    "gulp-sourcemaps": "^1.5.1",
    "gulp-uglify": "~0.1.0",
    "gulp-util": "~2.2.12",
    "lodash": "^3.6.0",
    "main-bower-files": "^2.6.2",
    "marked": "~0.3.0",
    "moment": "^2.10.0",
    "run-sequence": "^1.0.2"
  },
  "browser": {
    "modernizr": "./bower_components/foundation/js/vendor/modernizr.js",
    "jquery": "./src/js/vendors/jquery-1.11.2.js",
    "jquery-placeholder": "./bower_components/jquery-placeholder/jquery.placeholder.js",
    "jquery-cookie": "./bower_components/jquery.cookie/jquery.cookie.js",
    "fastclick": "./bower_components/fastclick/lib/fastclick.js",
    "foundation": "./bower_components/foundation/js/foundation.js",
    "knockout": "./bower_components/knockout/dist/knockout.js",
    "d3": "./bower_components/d3/d3.js"
  },
  "browserify": {
    "transform": "browserify-shim"
  },
  "browserify-shim": {
    "modernizr": "Modernizr",
    "jquery": "$",
    "knockout": "ko",
    "d3": "d3"
  },
  "dependencies": {}
}
it lets me import d3, ko, $ like I would commonjs libs so jslint won't yell at me.

Shaggar
Apr 26, 2006

pram posted:

this looks neat but the bower libs i use arent commonjs and using the browserify and vinyl plugins for gulp doesnt seem to be working right

cant wait for es6 modules because holy poo poo this nodejs rabbit hole is complete poo poo

node is garbage.

Zlodo
Nov 25, 2006

pointsofdata posted:

Is there something like linq in c++?

https://cpplinq.codeplex.com/

although with concepts and ranges in the standard library (which may be in c++17) it will eventually be possible to compose STL algorithms in a way that will look a lot like linq

pram
Jun 10, 2001

MeruFM posted:

I had the same problem so I googled around and came up with this monstrocity for package.json


it lets me import d3, ko, $ like I would commonjs libs so jslint won't yell at me.

can i see your gulpfile?

MeruFM
Jul 27, 2010

pram posted:

can i see your gulpfile?

code:
'use strict';
var gulp = require('gulp');
// this is an arbitrary object that loads all gulp plugins in package.json.
var $ = require('gulp-load-plugins')();
var del = require('del');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var runSequence = require('run-sequence');

gulp.task('browser-sync-dev', function() {
  browserSync({
    server: {
      baseDir: "./dev"
    },
    open: false,
    port: 8081
  });
});

gulp.task('sass', function() {
  return gulp.src('./src/scss/main.scss')
    .pipe($.sass())
    .pipe($.minifyCss())
    .pipe($.rev())
    .pipe(gulp.dest('./dist/css'))
    .pipe($.rev.manifest("rev-css.json"))
    .pipe(gulp.dest('manifest'));
});

gulp.task('sass-dev', function() {
  return gulp.src('./src/scss/**/*.scss')
    .pipe($.plumber())
    .pipe($.sourcemaps.init())
      .pipe($.sass())
    .pipe($.sourcemaps.write())
    .pipe(gulp.dest('dev/css'));
});


gulp.task('js', function() {
  return gulp.src('src/js/app.js')
    .pipe($.plumber())
    .pipe( $.browserify())
    .pipe( $.uglify() )
    .pipe($.rev())
    .pipe( gulp.dest('dist/js/'))
    .pipe($.rev.manifest("rev-js.json"))
    .pipe(gulp.dest('manifest'));
});

gulp.task('js-dev', function() {
  return gulp.src('src/js/app.js')
    .pipe($.plumber())
    .pipe( $.browserify({
      debug: true
    }))
    .pipe( gulp.dest('dev/js/'));
});

gulp.task('images', function() {
  return gulp.src('./src/images/**/*')
    .pipe($.imagemin({
      progressive: true
    }))
    .pipe($.rev())
    .pipe(gulp.dest('./dist/images'))
    .pipe($.rev.manifest("rev-img.json"))
    .pipe(gulp.dest('manifest'));
});

gulp.task('images-dev', function() {
  return gulp.src('./src/images/**/*')
    .pipe(gulp.dest('./dev/images'));
});

gulp.task('templates', function() {
  var manifestCSS = gulp.src("./manifest/rev-css.json");
  var manifestJS = gulp.src("./manifest/rev-js.json");
  var manifestIMG = gulp.src("./manifest/rev-img.json");
  return gulp.src('src/**/*.jade')
    .pipe($.plumber())
    .pipe($.jade({
      pretty: false,
      debug: false,
      compileDebug: false
    }))
    .pipe($.revReplace({manifest: manifestCSS}))
    .pipe($.revReplace({manifest: manifestJS}))
    .pipe($.revReplace({manifest: manifestIMG}))
    .pipe( gulp.dest('dist/') );
});

gulp.task('templates-dev', function() {
  return gulp.src('src/**/*.jade')
    .pipe($.plumber())
    .pipe($.jade({
      pretty: true,
    }))
    .pipe( gulp.dest('dev/') );
});

gulp.task('build', function(){
  runSequence(['sass', 'js', 'images'],
              'templates');
});

gulp.task('build-dev', ['sass-dev', 'js-dev', 'templates-dev', 'images-dev']);

gulp.task('serve', function () {
  runSequence('build-dev', 'browser-sync-dev');
  gulp.watch('src/scss/**/*.{scss,sass}',['sass-dev', reload]);
  gulp.watch('src/js/**/*.js',['js-dev', reload]);
  gulp.watch('src/images/**/*',['images-dev', reload]);
  gulp.watch('src/**/*.jade',['templates-dev', reload]);
});

gulp.task('clean', function() {
  del('./dist');
  del('./dev');
  del('./manifest');
});

gulp.task('default', ['serve']);

MeruFM fucked around with this message at 20:37 on Jun 19, 2015

pram
Jun 10, 2001
thanks

MeruFM
Jul 27, 2010
it's not perfect.

i think if the jade or sass is hosed up, it pops an error and you have to restart the server instead of auto-reloading the next time you change.

brap
Aug 23, 2004

Grimey Drawer
what's a good book for learning modern c++ (I guess while also learning enough about "old" c++ to deal with real codebases)

Shaggar
Apr 26, 2006

MeruFM posted:

code:
'use strict';
var gulp = require('gulp');
// this is an arbitrary object that loads all gulp plugins in package.json.
var $ = require('gulp-load-plugins')();
var del = require('del');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var runSequence = require('run-sequence');

gulp.task('browser-sync-dev', function() {
  browserSync({
    server: {
      baseDir: "./dev"
    },
    open: false,
    port: 8081
  });
});

gulp.task('sass', function() {
  return gulp.src('./src/scss/main.scss')
    .pipe($.sass())
    .pipe($.minifyCss())
    .pipe($.rev())
    .pipe(gulp.dest('./dist/css'))
    .pipe($.rev.manifest("rev-css.json"))
    .pipe(gulp.dest('manifest'));
});

gulp.task('sass-dev', function() {
  return gulp.src('./src/scss/**/*.scss')
    .pipe($.plumber())
    .pipe($.sourcemaps.init())
      .pipe($.sass())
    .pipe($.sourcemaps.write())
    .pipe(gulp.dest('dev/css'));
});


gulp.task('js', function() {
  return gulp.src('src/js/app.js')
    .pipe($.plumber())
    .pipe( $.browserify())
    .pipe( $.uglify() )
    .pipe($.rev())
    .pipe( gulp.dest('dist/js/'))
    .pipe($.rev.manifest("rev-js.json"))
    .pipe(gulp.dest('manifest'));
});

gulp.task('js-dev', function() {
  return gulp.src('src/js/app.js')
    .pipe($.plumber())
    .pipe( $.browserify({
      debug: true
    }))
    .pipe( gulp.dest('dev/js/'));
});

gulp.task('images', function() {
  return gulp.src('./src/images/**/*')
    .pipe($.imagemin({
      progressive: true
    }))
    .pipe($.rev())
    .pipe(gulp.dest('./dist/images'))
    .pipe($.rev.manifest("rev-img.json"))
    .pipe(gulp.dest('manifest'));
});

gulp.task('images-dev', function() {
  return gulp.src('./src/images/**/*')
    .pipe(gulp.dest('./dev/images'));
});

gulp.task('templates', function() {
  var manifestCSS = gulp.src("./manifest/rev-css.json");
  var manifestJS = gulp.src("./manifest/rev-js.json");
  var manifestIMG = gulp.src("./manifest/rev-img.json");
  return gulp.src('src/**/*.jade')
    .pipe($.plumber())
    .pipe($.jade({
      pretty: false,
      debug: false,
      compileDebug: false
    }))
    .pipe($.revReplace({manifest: manifestCSS}))
    .pipe($.revReplace({manifest: manifestJS}))
    .pipe($.revReplace({manifest: manifestIMG}))
    .pipe( gulp.dest('dist/') );
});

gulp.task('templates-dev', function() {
  return gulp.src('src/**/*.jade')
    .pipe($.plumber())
    .pipe($.jade({
      pretty: true,
    }))
    .pipe( gulp.dest('dev/') );
});

gulp.task('build', function(){
  runSequence(['sass', 'js', 'images'],
              'templates');
});

gulp.task('build-dev', ['sass-dev', 'js-dev', 'templates-dev', 'images-dev']);

gulp.task('serve', function () {
  runSequence('build-dev', 'browser-sync-dev');
  gulp.watch('src/scss/**/*.{scss,sass}',['sass-dev', reload]);
  gulp.watch('src/js/**/*.js',['js-dev', reload]);
  gulp.watch('src/images/**/*',['images-dev', reload]);
  gulp.watch('src/**/*.jade',['templates-dev', reload]);
});

gulp.task('clean', function() {
  del('./dist');
  del('./dev');
  del('./manifest');
});

gulp.task('default', ['serve']);


:barf:

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

fleshweasel posted:

what's a good book for learning modern c++ (I guess while also learning enough about "old" c++ to deal with real codebases)

"the c++ programming language, 4th edition" is pretty good. it's huge, but if you're just coming into the language it's super useful. written by stroustrup himself

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
welp lol @ awful app

VikingofRock
Aug 24, 2008




fleshweasel posted:

what's a good book for learning modern c++ (I guess while also learning enough about "old" c++ to deal with real codebases)

Dessert Rose posted:

"the c++ programming language, 4th edition" is pretty good. it's huge, but if you're just coming into the language it's super useful. written by stroustrup himself

This is excellent advice. I'll add that if you already know some C++ and just want to focus on the modern stuff, "Effective Modern C++" by Scott Meyers is pretty good too.

jony neuemonic
Nov 13, 2009

is http://www.learncpp.com any good? seems like it's been kept up to date when the standards changed.

MeruFM
Jul 27, 2010

:smug:

Bloody
Mar 3, 2013

i want a thing thats just like two columns. on the left, bad c-like way of doing thing in c++, on the right, idiomatic c++ way of doing thing in c++

Ralith
Jan 12, 2011

I see a ship in the harbor
I can and shall obey
But if it wasn't for your misfortune
I'd be a heavenly person today
Just browse http://en.cppreference.com/w/ at random. It is a good reference.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Bloody posted:

i want a thing thats just like two columns. on the left, bad c-like way of doing thing in c++, on the right, idiomatic c++ way of doing thing in c++

VikingofRock posted:

"Effective Modern C++" by Scott Meyers is pretty good too.

jesus WEP
Oct 17, 2004


god dammit dessert you're almost making me want to learn cpp

jony neuemonic
Nov 13, 2009

St Evan Echoes posted:

god dammit dessert you're almost making me want to learn cpp

right? i'm too easily influenced by people hyping things in here.

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

St Evan Echoes posted:

god dammit dessert you're almost making me want to learn cpp
pick a project first then choose a toolset

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...

coffeetable posted:

pick a project first then choose a toolset

this. please don't do stupid crap that is better expressed in a higher level language in c++.

like my coworker wrote a log parsing tool in cpp lol

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
if you have to do any extensive string bashing, c++ is probably not the language for you, unless you really need to do that with a file that's enormous (tens-hundreds of gb) or performance/memory critical

for example, a low-latency network message parser is probably well-suited for c++ for a variety of reasons

Zlodo
Nov 25, 2006
well if you do crazy expression template poo poo writing a parser in c++ can be kinda neat as you can write your grammar directly, with lambdas directly inserted in the middle to perform actions when specific grammar productions are encountered:

C++ code:
    auto InheritanceList =
        Term( ':' )
        && List( ClassRef >> AddSuperClass, ~Space & Term( ',' ) & ~Space );

    auto Property =
        String( "property") & Space & Type && ( Identifier | Error( "identifier expected." ) )
            >> AddProperty
        && ( Term( ';' ) | Error( "';' expected." ) );

    auto ConstructorName = DynRule( [&]{ return String( className ); } );

    auto MethodName =
        ( At( ConstructorName ) & Error( "invalid method name." ) )
        | ( Identifier >> [&]( const auto& r ){ functionName = RangeToStr( r ); } );

    auto StaticMethod =
        String( "static" )
        && ReturnType
        && MethodName
        && ParameterList
        && ( Term( ';' ) | Error( "';' expected." ) )
            >> [&]( const auto& r )
            {
                assert( pCurrentClass );
                assert( pCurrentPrototype );
                pCurrentClass->addStaticMethod( functionName, pCurrentPrototype );
            };

    auto Constructor =
        ConstructorName
        && ParameterList
        && ( Term( ';' ) | Error( "';' expected." ) )
            >> [&]( const auto& r )
            {
                assert( pCurrentClass );
                assert( pCurrentPrototype );
                pCurrentClass->addCtor( pCurrentPrototype );
            };

    auto Method =
        ReturnType
        && MethodName
        && ParameterList
        && ~( String( "const" )
            >> [&]( const auto& r )
            {
                assert( pCurrentPrototype );
                pCurrentPrototype->setConst();
            } )
        && ( Term( ';' ) | Error( "';' expected." ) )
            >> [&]( const auto& r )
            {
                assert( pCurrentClass );
                assert( pCurrentPrototype );
                pCurrentClass->addMethod( functionName, pCurrentPrototype );
            };

    auto ClassElement =
        Enum
        | Property
        | StaticMethod
        | Constructor
        | Method
        | FlagList;

    auto ClassContent = ~List( ClassElement, ~Space );

    auto Class =
        ~( TemplateParamList >> [&]( const auto& r ){ bTemplateClass = true; } )
        && String( "class" )
        && ( ( Identifier | Error( "identifier expected." ) )
            >= [&]( const auto& r ) { className = RangeToStr( r ); } )
            >> NewClass
        && ~( String( "in" ) && HeaderName >> SetClassHeader )
        && ~InheritanceList
        && ( Term( '{' ) | Error( "'{' expected." ) )
        && ClassContent
        && ( Term( '}' ) | Error( "'}' expected." ) )
        && ( ( Term( ';' ) | Error( "';' expected." ) )
            >= [&]( const auto& r ) { templateParamSet.clear(); } )
            >> AddClass;
the compilation time tends to get awful and every small compilation error turns into screen upon screens of ridiculously nested templates but its kinda fun to use

JewKiller 3000
Nov 28, 2006

by Lowtax

Zlodo posted:

well if you do crazy expression template poo poo writing a parser in c++ can be kinda neat as you can write your grammar directly, with lambdas directly inserted in the middle to perform actions when specific grammar productions are encountered:

:barf:

the compilation time tends to get awful and every small compilation error turns into screen upon screens of ridiculously nested templates but its kinda fun to use

this is some stockholm syndrome poo poo

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



ragel is really neat for writing parsers imo

zlodos stuff is p much a DSL anyway so why not go whole hog?

VikingofRock
Aug 24, 2008




Has anyone here used boost::spirit? If so, how is it?

Soricidus
Oct 21, 2010
freedom-hating statist shill

shaggar was right

AWWNAW
Dec 30, 2008

VikingofRock posted:

Has anyone here used boost::spirit? If so, how is it?

i think i read some internal google thing that strictly prohibits any use of it cuz apparently it encourages completely unmaintainable horse poo poo

Zlodo
Nov 25, 2006

VikingofRock posted:

Has anyone here used boost::spirit? If so, how is it?

I tried it a while ago but it was before c++11 and i remember that it was pretty awkward without lambdas
its probably better now but meanwhile i tried https://github.com/ColinH/PEGTL and using nested templates to define rules instead of custom operators is really bad so i rolled my own expression template peg parsing thing (its not actually that hard)

its probably better to use a real parser generator but i only use it to parse a simple thing for a tool and i dont mind having a slightly worse syntax but have more flexibility in the way i interface my parser with the rest of my code

Valeyard
Mar 30, 2012


Grimey Drawer

AWWNAW posted:

i think i read some internal google thing that strictly prohibits any use of it cuz apparently it encourages completely unmaintainable horse poo poo

you sure they werent talking about Go?

VikingofRock
Aug 24, 2008




AWWNAW posted:

i think i read some internal google thing that strictly prohibits any use of it cuz apparently it encourages completely unmaintainable horse poo poo

To be fair, you should probably take Google's C++ opinions with a grain of salt.

Brain Candy
May 18, 2006

VikingofRock posted:

To be fair, you should probably take Google's C++ opinions with a grain of salt.

you are asking me to trust the angry opinions of somebody who self-describes as a "<language> programmer"

pram
Jun 10, 2001

Valeyard posted:

you sure they werent talking about Go?

deep irony from captain python

VikingofRock
Aug 24, 2008




Brain Candy posted:

you are asking me to trust the angry opinions of somebody who self-describes as a "<language> programmer"

His writing is bad but his points are all good.

Adbot
ADBOT LOVES YOU

Valeyard
Mar 30, 2012


Grimey Drawer

pram posted:

deep irony from captain python

it was a coin flip between saying python or go or anything else tbf

  • Locked thread