5 ms·
> Going back to plain JavaScript might not be quite as concise, but the fact that the code always does exactly what you want it to, no surprises (as long as you
by Lazare 13y ago
> Going back to plain JavaScript might not be quite as concise, but the fact that the code always does exactly what you want it to, no surprises (as long as you know the language), let me program in peace again.
I'm sympathetic to your point, but this seems entirely wrong in context, because JS exhibits all the flaws you decry and more.
JS is often an ambiguous language, and often behaves poorly in edge cases. Even in the specific example (variable scope) the JS rules are arcane, poorly documented, confuse the hell out of even experienced JS programmers, and are hard to debug. Unless your argument boils down to "I know JS much better than Coffeescript, so its edge cases are less surprising to me", where in the world is the "win" from switching to Javascript from Coffeescript?
For what its worth, I've used Coffeescript more than you, and I find it does have the problems you state, as do pretty much all languages; it's one of degree. Coffeescript is worse than, eg, lua, but better than, eg, Javascript. And of the feasible languages to write code that will run in the browser, Coffeescript is the best choice (if the decision is purely based on "will my code do what I want/are edge cases going to bite me unpleasantly"). But that's just my personal experience. :)
- masklinn 13y ago> Even in the specific example (variable scope) the JS rules are arcane, poorly documented, confuse the hell out of even experienced JS programmers, and are hard to debug. When using strict mode, which you should be, you're about 0/4. Your second incorrect complain is especially galling as ECMA-262 goes to extensive length in specifying it (section 10 "Executable Code and Execution Contexts" of the ECMA-262 5.1 specification)
- ender7 13y agoI don't think I agree with your point. Javascript is a very small language, and while there are a number of gotchas they are enumerable and well-defined. Central concepts: - Objects - Prototypes - Scope chains - Closures - Function.bind, Function.apply/Function.call Gotchas: - Behavior of the "new" operator - Value of "this" - Type coercion, falsiness of "", == vs. === - var hoisting - if/for/while do not create scope - function expression vs. function declaration Many of the gotchas are self-evident if you learn the central concepts.
- crazygringo 13y agoExactly. I can deal with "gotchas" and edge cases as long as they're documented and I can memorize them -- which is 100% the case with JavaScript. The reason I'll never use CoffeeScript again isn't because of its gotchas -- it's because there's no way to learn them. They're not documented. They're not predictable from principles. They're completely hidden.
- michaelwww 13y agoIt sounds like CoffeeScript violates the principle of least surprise [1] for you (and me too.) On the other hand, when I use a language like C# (whose author is also behind TypeScript) I often find myself thinking "it should work this way" and then finding out is does work that way. [1] https://en.wikipedia.org/wiki/Principle_of_least_astonishment https://en.wikipedia.org/wiki/Principle_of_least_astonishmen...