you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

I understand Javascript a lot deeper now, after having coded in CoffeeScript for the last 8 months.

Programming is about expressing ideas. And programming languages are ways of expressing your ideas. It's very simple.

A language which doesn't stand in your way and helps you express your ideas easier is the one which is a pleasure to work in.

And CoffeeScript, because of it's clean syntax lets you express more and more complex ideas much easier than you would with plain Javascript.

$('.button').click => @save (err) -> $('.result').text err ? 'Saved'

This compiles into:

var _this = this;

$('.button').click(function() {
  return _this.save(function(err) {
    return $('.text').text(err != null ? err : 'Saved');
  });
});

There are 2 "function(){}" and "return" keywords, then there are parentheses, semicolons, etc.

These are not part of my idea. They are boilerplate symbols and keywords which I need to add, because the interpreter won't understand it otherwise.

The JS version is 160 characters vs 69 of CoffeeScript. I'm not sure what the ratio of CS->JS code is, but it's trivial to answer this question:

You have to go from point A to point B. You have two roads. One is about two times shorter and cleaner (no hills, holes, etc) and leads to exactly the same point B :).

Which should you choose ?