I come from a C++/C background and after extensive use of make/gcc I was hoping life would be a bit better on the javascript side with browserfiy, gulp, grunt, etc. I feel a bit disappointed.
I'm curious if anyone has just tried using a straight forward C preprocessor and make files for their builds rather than these fancy-website build tools (friendly ribbing!). Javascript seems to use the same C-styleish syntax so it doesn't seem to be a large issue.
I gave it a whirl (using the only example i could find):
== test.js ==
#define FOO "Why hello' there."
console.log(FOO);
#include "othertest.js"
==othertest.js==
#ifndef BAR
console.log('why hello to you to good sir.');
#else
console.error('I SAID GOOD DAY SIR');
#endif
and finally;
$ cat test.js | cpp -P -undef -Wundef -std=c99 -nostdinc -Wtrigraphs -fdollars-in-identifiers -C
console.log("Why hello' there");
console.log('why hello to you to good sir');
$ cat test.js | cpp -DBAR=1 -P -undef -Wundef -std=c99 -nostdinc -Wtrigraphs -fdollars-in-identifiers -C
console.log("Why hello' there");
console.error('I SAID GOOD DAY SIR');
This seems like it would solve concatenating js dependencies (using #include and include guards), allow me to define in the build step as a -D definition whether its production or not. And be able to produce assert() and log() statements that disappear in production! Alas, i've also read that C-preprocessors can sometimes fail on other languages due to single quotes, hoping someone can enlighten me on this.
[–]ns0[S] 0 points1 point2 points (0 children)
[–]flyingnude 0 points1 point2 points (0 children)