Hacker News new | ask | show | jobs
by laughinghan 5174 days ago
Some may claim that 'coffeescript is javascript'... . People that say this don't really understand the difference between DOM [sic] and Javascript, and it is very telling.

I say this, and I believe I know the difference between the DOM and JavaScript, and have since before I've said that CoffeeScript "is" JavaScript. The DOM is a representation of HTML and XML document specified by the W3C, with an API for manipulation by scripts typically written in JavaScript. JavaScript is a trademark owned by the Oracle Corporation and licensed by the Mozilla Foundation, used to refer to a programming language standardized as ECMAScript, implemented by a whole bunch of vendors in a largely cross-compatible, ECMAScript Standard-compliant fashion, but often with many proprietary extensions. Would you very much mind explaining to me what I don't know about the difference between the DOM and JavaScript?

Do you agree that ECMAScript "is" JavaScript? Would you say ECMAScript Harmony "is" JavaScript? What if some future version of ECMAScript breaks backwards compatibility with ECMAScript 4, let's say, by vastly simplifying ==, but everything else stayed the same? Would you say this ECMAScript Imaginary wasn't JavaScript? It might be incompatible, but you'd still call it JavaScript, right? The point being, there is some backwards-compatibility-breaking change you would accept as not making a language "not JavaScript". So now our difference in opinion is to whether CoffeeScript's differences are enough to make it "not JavaScript".

I argue for my humble opinion that the semantics of CoffeeScript are so similar to that of ECMAScript 4 that just like ECMAScript Imaginary, you just have to take 5 minutes to read about what's different, and you'll be able to understand it just as easily.

There is a wealth of experience and all the 'gotchas' are well documented and there aren't really that many of them if you don't count anything to do with the DOM.

I agree with this. In fact, I have also been frustrated with people who don't know the difference between the DOM and JavaScript. I have never experienced this with CoffeeScript fanatics, however.

If you think changing the rules of the language regularly is a good way to develop software, then we don't have anything further to talk about.

If you think no one should ever attempt to improve an existing programming language, we also don't have anything further to talk about.

They are both straw men. Using an experimental tool is always associated with problems with the ground changing underneath you, that doesn't mean it is always not worth it. It's a tradeoff, and with "good practices", it can be worth it if you develop faster and rarely write forwards-incompatible code.

You can't have the same variable name used twice in the same source file.

The problem you are attempting to describe is the reason I currently use exclusively JavaScript in all my projects, however your description is inaccurate and misleading. You totally can have the same variable name twice in the same file. However, if one of them is in a inner scope than the other, the only way for the inner scope to shadow the outer scope to avoid munging a variable in an outer scope is for it to be a parameter to the function.

It is more difficult to read coffeescript because of ambiguity that you don't get with C style syntax.

I'm not sure what you mean by ambiguity, but I am quite certain that CoffeeScript has a provably unambiguous grammar.