Ok, I'll pass on CoffeeScript
github.com
github.com
Way to contribute to elevating the state of discussion on the internet.
foo = 1
fun = ->
foo = 2
fun()
alert(foo) #1
and foo = 1
fun = ->
foo := 2
fun()
alert(foo) #2
But I'm sure haters will find something to hate in LiveScript too. foo = 42 to mean JavaScript's var foo = 42;
foo := 42 to mean JavaScript's foo = 42;
I adore this syntax, it's amazingly easy to read. Where can I get it?The issue's been beaten to death, and the consensus among the pro-Coffeescript crowd is that it's acceptable, because you shouldn't be shadowing variables anyway, and the consensus amoung the anti-Coffeescript crowd is that it's terrible because it removes control from the developer.
a = 3
b = ->
for a in [6,7,8]
c = a
b()
console.log(a)
would print "3". In coffeescript 1.3.3 it prints "8".The solution is either to rename one of the 'a' variables or add
`var a`
in the b() function.Coming from C where I always (ok 99% of the time) do:
for (int i=0; ...)
the loop scoping rules in the 1.3.1 version of coffeescript felt natural. The 1.3.3 change feels stupid.Sure. But how about because actually learning JavaScript is better than coding with training wheels?