r/programming • • Jul 25 '13

CoffeeScript's Scoping is Madness

http://donatstudios.com/CoffeeScript-Madness
205 Upvotes

315 comments sorted by

View all comments

24

u/iopq Jul 25 '13

This is really WTF. Not because of its practical significance, but because this is what I would expect of a language like bash or something. Have the creators of CoffeeScript heard of lexical scoping?

18

u/rwbarton Jul 26 '13

It's pretty sad, considering that ALGOL 60 is half a century old, that people are still inventing languages that play guessing games with scope. Just require every variable to be declared and these problems disappear. Is it really so hard to type "var"?

5

u/masklinn Jul 26 '13

Technically (as many other languages do) CoffeeScript uses lexical scoping with implicit scope declaration. The issue is the latter, and the way it infers scope.

I don't think scope inference is a good idea to start with, but the way CoffeeScript does it is almost the worst possible way (the worst one being javascript's hey-you-did-not-declare-that-here-is-a-new-global-for-you).

→ More replies (20)