News for hackers. Stuff that matters.
Re:Why CoffeeScript Isn't the Answer by joev_ on Sunday March 30, 2014 @03:22PM (#7497502)
The point is it doesn't pass static verification. It doesn't compile. It's a rather silly thing for the author to argue imho.
Re:Why CoffeeScript Isn't the Answer by implicit on Sunday March 30, 2014 @03:50PM (#7497619)
Agreed. I was responding more to the assertion that CoffeeScript doesn't have a problem with variable scoping rules.

It does and the consequences are scary.

Re:Why CoffeeScript Isn't the Answer by couchand on Sunday March 30, 2014 @04:14PM (#7497726)
You're right that the scoping rules in CoffeeScript are unintuitive for someone coming from a statically-typed, declare-everything paradigm. But I'd hesitate to call it a problem. It's a feature not a bug that the same symbol in nested scopes always refers to the same variable. As I said previously, I believe code that relies on variable shadowing to work correctly is broken.

I've been hit by the scoping rules many times, but every time I ask myself why I'm using identifiers like i, j or x to refer to different variables in nested scopes anyway. Names like that should be reserved for only the tightest of scopes.

Is there another aspect of the scoping rules that you're referring to?

Re:Why CoffeeScript Isn't the Answer by implicit on Sunday March 30, 2014 @05:31PM (#7498036)
I agree that shadowing is bad.

Implicitly scoping variables to their lexically-outermost point of use is a terrible solution, though: changing anything in any outer scope can completely change the meaning of code in all nested scopes. That's really really bad.

A much better syntax would is to require the 'var' keyword to denote the scope of every variable, but reject shadowed symbols at compile time.

Re:Why CoffeeScript Isn't the Answer by cm127 on Monday March 31, 2014 @05:50AM (#7500516)
You nailed why I like playing with CoffeeScript: it makes me a better JavaScript programmer. Thinking about each line, the variable names, etc. It's definitely not something I would want to use in a rush.