I want to note that the numbers can be deceiving though because they use different mechanisms to record elapsed time.
When I ran the same task though Unix `time` I got numbers that were much closer, although still in Gulp's favour.
29 karma · joined December 8, 2009
[ my public key: https://keybase.io/jaysoo; my proof: https://keybase.io/jaysoo/sigs/yTy-9ISNw5x5E9888xpIL14Nb1ZPkQE5-gF8cEN1jjw ]
I want to note that the numbers can be deceiving though because they use different mechanisms to record elapsed time.
When I ran the same task though Unix `time` I got numbers that were much closer, although still in Gulp's favour.
It's useful for something like:
f = (options) ->
options.foo or= 'bar'
# ...It's always good to look at the pro/cons before choosing a language, so I think discussions like this is good.
That being said, some of the problems this article points out can be addressed by going back to more JS style.
e.g. Not relying on implicit parentheses/commas/braces
I like the "Fancy" for loop because it's closer to what I do in Python (yes I know they are not exactly the same). Same thing with the "Tricky" if statements.
Also the redefinition shortcuts provided in CoffeeScript is pretty much what I do in plain JS anyway.
e.g.
JS: foo = foo || 'bar';
CS:
foo or= 'bar'Those statements are basically (as per ECMA-262 11.9.3):
0 === Number('0') 0 === Number('') '0' === ''
This is also not free-market capitalism. I'm not sure what you would call it.
Also, Bell/Rogers/Telus have the advantage of offering bundles if you use them for cable/satellite+cell phone+Internet, whereas a lot of smaller ISPs would not able to do such things. This screams anti-competition.
FYI, I don't mind paying per usage as long a the rates are reasonable. How about charging us $10-15 for connection fees, and then $0.25/GB of transfer?
var say = (function() {
var savedArgs = [];
return (function recurse () {
if (arguments.length) {
for (var i=0, arg; arg=arguments[i]; i++) {
savedArgs.push(arg);
}
return recurse;
} else {
alert(savedArgs.join(' '));
savedArgs = [];
}
});
})();// e.g. say('Hello')('World')('!!')();
// --> alerts "Hello World !!"
The HTTP Response Splitting vulnerability can have many implications, XSS and CSRF attacks are just some examples.
In fact, Crockford has mentioned this as well: http://javascript.crockford.com/code.html
"JavaScript does not have block scope, so defining variables in blocks can confuse programmers who are experienced with other C family languages."
Which is why this code works:
(function() {
for (var i=0; i<100; i++);
alert(i);
})();Notice the variable `i` is accessible from outside the for-loop.
For example, if you ran the code below in FireBug you'll get the same results (minor variance aside).
function foo() { var a = 0; for (var i=0, j=a; i<10000000; i++) { var x = j+i; } }
function bar() { var a = 0; for (var i=0; i<10000000; i++) { var x = a+i; } }
(function() { var start = new Date().getTime(), end; foo(); end = new Date().getTime(); console.log(end-start); })();
(function() { var start = new Date().getTime(), end; bar(); end = new Date().getTime(); console.log(end-start); })();
That doesn't even make sense. The for-loop block doesn't create a new scope, so it's perfectly valid to refer to the variable `a`. Plus, even if you create a new scope, you can still refer to `a` due to closure.