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

CoffeeScript "fixes" javascript in many very essential ways. The most important fix is the lack of global variables. It's all too easy to accidentally forget a var on an assignment and all of a sudden you get a global variable that can cause havok. CoffeeScript handles variable scoping extremely well, and if you need a global, you can use the more explicit: window.var = ....

Also it's class system and function binding (=>) is something I feel I can no longer live without.



I don't know any thing about CoffeeScript, but static analysis tools like the Google Closure Compiler can help you take care of global variable problems and a whole lot more. Using Closure Compiler, you are forced to document your code with their enhanced version of jsDocs, so CC will make sure that if your method returns null or a list of strings, that anywhere that method is used, you don't try to treat the returned value as a string or object, for instance.

How does coffee script play with existing object oriented JS libraries? Is there compile-time type checking?


I always thought it would be cool if CoffeeScript's generated JS code added Closure Compiler annotations, such as @const and @param types. Let the user minify/optimize the generated JS using their favorite tools.

https://code.google.com/closure/compiler/docs/js-for-compile...


This fork of CoffeeScript does: https://github.com/jstrachan/coffee-script/blob/master/TypeA.... I for one would also love it if this got rolled into mainline. I use Closure at work, and I'd love to be using CoffeeScript with it.


Thanks! I hadn't seen this "UberScript" before, though I was kinda hoping the Closure annotations could be inferred "for free" without changes to the CoffeeScript language. <:)


Automatically annotating JavaScript code for JSDoc would really helpful.


One of the niceties of CoffeeScript generated code is that it's totally readable and idiomatic Javascript with a dose of JSLint on top.

To misquote the "Pragmatic Programmer" book... don't use wizard code you don't understand. The opposite applies in my opinion.


The golden rule of CoffeeScript is: "It's just JavaScript". The code compiles one-to-one into the equivalent JS, and there is no interpretation at runtime. http://coffeescript.org




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

Search: