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

From github: CoffeeScript: number = -42 if opposite

Javascript: if (opposite) number = -42;

How is coffeescript an advantage in this example? The javascript seems more readable to me as it more closely follows regular english grammar.

CoffeeScript: square = (x) -> x * x

Javascript: square = function(x) { return x * x; }

In this example, again the javascript seems more clear. The function actually has the word function in the declaration. I like that. Essentially coffeescript took out the word 'function' and 'return' and replaced curly braces with other symbols.



CoffeeScript is one of those things that one has to actually try to feel the full impact. Use it for a few days then return to javascript.


Inline conditionals on the left and the function keyword? From all the features that CoffeeScript offers it's kinda odd to focus on those minor details of taste and habit.


But it's one of the first things that is presented on the overview so naturally it's going to get lots of focus.


It's a bloody overview mate, it mentions everything in more-or-less random order :-)


You can write it either way in CS. Anyway, saying that CS is a huge improvement over JS doesn't imply that every single feature of CS is better than its JS counterpart.




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

Search: