Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
CoffeeScript - JavaScript the Good Parts (infoq.com)
36 points by icey on Sept 15, 2010 | hide | past | favorite | 8 comments


"The first person to create a pleasant end-to-end system for programming JavaScript web applications wins the next five years of web development, period."

That's the point which always got me going the first few times this language appeared on HN. A future developer with HTML5, video and audio, a library like sproutcore(note the recent news about Katz) in coffeescript matched up to a Sinatra-like base in CS running on node.js is going to be able to work like grease lightning. That world would be quite profitable in terms of the hosting opportunities (herokuish?), consulting and book deals. Much of it applies already to the node.js stuff I suppose. It's a pity Ruby or Python isn't in the browser as it would have the same multiplying effect (and add Python's vast libraries in other domains, at least on the server-side).


IronPython is in the browser at least... http://ironpython.net/browser/


And it apparently doesn't require Silverlight. Interesting.


It does require Silverlight (as do all DLR languages if you want them to run in the browser). Take a look at the js: http://gestalt.ironpython.net/dlr-latest.js


Ah, thanks for the clarification. The way the page phrased it made me think you just needed to include that Javascript and it would work. There are language implementations like that, so it seemed plausible. That's too bad.


"cleaning up the semantics of broken JavaScript constructs" I actually like JavaScript. So what does CoffeeScript fix?


Leaving features off the table and just talking about semantic cleanups, here's a few:

* Switch statement doesn't fall-through by default.

* Variables don't need to be declared with "var", and can't ever become global accidentally.

* Equality is strict, using `===`, if you want coercive equality, you coerce the object yourself.

* Loops that are used to generate functions close over their index variables, so that all inner functions don't share the final value of the index. This is the same problem that ECMAScript Harmony introduces "let" to solve.

* Splats largely replace use of the "arguments" object, so you don't get bit by "arguments" only being a faux-array.

* Comparisons can be chained, as in Python -- so you can write: "100 > x > 25", and have the answer be correct.

* Multiline strings are valid without having to escape the newline.

* And the big one: everything in CoffeeScript is an expression. Without having to use temporary variables, you can return the result of an if/else from a function, pass a comprehension (loop) directly into a function call, assign the result of a try/catch, and so on.

I love JavaScript semantics as well. I think it has the cleanest object/function model out there, in terms of scripting languages -- but that's not to say there aren't parts that can use a little touch-up.


Don't get me wrong. As I am learning JavaScript right now I am only interested in the real fixes and not the nice to have features. Chaining comparisons, multiline strings, everything is an expression are IMHO "just" nice features.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: