Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As every debate ought to say, we're each entitled to our own opinions, but not our own facts. My opinion--which I believe I have demonstrated to be a fact--is that it is possible to write sane CoffeeScript that is lexically scoped and not subject to misinterpretation.

It is a fact that it is possible to write CoffeeScript code that requires careful examination of the file to understand what it does, code which can also change if you alter something somewhere else in the file.

My opinion--which I also believe I have demonstrated to be a fact--is that it is possible to write sane JavaScript that is lexically scoped and not subject to misinterpretation.

It is clearly possible to write JavaScript code that requires careful examination of the file to understand what it does, acode which can also change if you alter something somewhere else in the file.

I have zero quibble with you or anyone else feeling CoffeeScript doesn't solve a problem for them. I have zero quibble with you or anyone else saying "Notwithstanding the fact that CoffeeScript is a lexically scoped language, my opinion is that I hate it."

My only quibble--and it is minor--is that it is not possible to say that CoffeeScript function-local variables don't work like JavaScript function-local variables and that you can confuse the two, since without the var keyword nobody can look at a CoffeeScript file and think they are looking at function-local variables.

We both agree on the fact that a file with variables that are not parameters in CoffeeScript has different semantics from a file with variables that are neither parameters nor function-local in JavaScript.

If your opinion is that this is a fatal flaw, well, who am I to argue with the fact that this is your opinion? I have a different opinion, and we are both entitled to same provided neither of us claim it to be a fact.



My assertion is that CoffeeScript is not an alternative syntax for JavaScript because of differences in scoping. My opinion is that this is not a good design choice because it increases the separation from the original language, requiring that someone who already knows JavaScript additionally learn CoffeeScript.

You can take the rest of my original comment as a rehashing of my evaluation of CoffeeScript, since I only see it when it appers on Hacker News.


In practice, the scoping difference that you run into 99% of the time is that implicit var keywords are in front of variables that haven't been seen in the current scope, and you have to assign globals to your top level scope (window in the browser). How long did it take me to bridge that separation from the original language? Oh, about a minute.


you shouldn't have to have a minute or even second considering the idiosyncracies of the underlying language...


I've made a one-time investment of a minuscule amount of time and have been raking in the saved time and effort from not having to type var statements or track down lack-of-var bugs.

Pure profit for me, but as always YMMV.


Have you tried it? I had the same opinion for a while, but after I wrote some code, I found the translated code easy to understand - and the language itself helpful and consistent.


> It is possible to write sane CoffeeScript that is lexically scoped and not subject to misinterpretation.

Possible is an extremely low bar. We hold ourselves to a higher standard these days in computer science, including language design.

It is possible to write sane INTERCAL that is (however INTERCAL is scoped) and not subject to misinterpretation.


This post does not attempt to compare CoffeeScript to INTERCAL or JavaScript as an overall design exercise. It simply points out an error that some people have made in characterizing CoffeeScript as lacking lexical scope.

It does point out that it has function-level lexical scope and that it has a construct for creating block scope which is almost identical to "let" as found in Scheme.

You can decide for yourself whether this is an advance on JavaScript or a retreat to the 1970s. If I had to defend the entire language every time I discussed CoffeeScript, mys posts would contain even more verbiage and repetition than they already do.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: