12 points · by jay_kyburz · 11y ago · 11 comments
http://raganwald.com/2013/07/27/Ive-always-been-mad.html
http://lucumr.pocoo.org/2011/12/22/implicit-scoping-in-coffeescript/
http://www.reddit.com/r/programming/comments/1j1cw7/coffeescripts_scoping_is_madness/
I work in Python on the server and JavaScript on the client all day long and I really do think syntax matters.
I would love a client language that was as clean and beautiful as CoffeeScipt but I think this issue is a show stopper for me.
CS makes scoping assumptions for you, because it wants to avoid syntactic clutter like "var. Maybe you'd like a different default assumption. Maybe you'd prefer to add in scoping keywords/sigils. These issues are full of tradeoffs.
The worst thing that can happen, though, is for there to be two nearly identical implementations, differing only by their subtle treatment of scope. If you think it's a showstopper now, imagine a world where your code silently manifests a variable binding security hole because you used a different fork of CoffeeScript.
It's probably quite easy to implement technically. It's probably much harder to come up with a logical, coherent, and consistent model of how it "should" work in all ofthe corner cases.
It's probably extremely difficult to accomplish socially (nobody will use the fork, and nobody will want to touch code that works on the assumption you're running the fork). Finally, it's probably actively damaging to the community as a whole to even attempt to fork over a relatively minor, ambiguous and, and opinionated like this, and I hope nobody tries it.
If I did take this on as a side project I would have no interest in making popular or having other developers use it. It would be for my internal projects.
There are a number of other things I would do to make the language more explicit. I'm a Python guy not a Ruby guy.
"LiveScript is a fork of Coco and an indirect descendant of CoffeeScript"
Does the compiler have any notion of scope?
edit: oh right, you need nonlocal or := if you want to access the outer scope.
When ES6 is a viable option, CoffeeScript can incorporate lexical scope in a backwards compatible way, and its scoping will become much less unexpected.