Should I learn CoffeeScript?

In the past 3 days, I read the Little Book on CoffeeScript and replaced some of the JavaScript in my website with CoffeeScript.  As an intermediate Ruby developer, CoffeeScript has been an absolute delight compared to JavaScript.  An intermediate Ruby/Python programmer that is only a JavaScript novice will actually write better code with CoffeeScript.

Here is a simple Person class we will use as an example.


class Person
  constructor: (name) ->
    @name = name

  speak: ->
    "My name is #{@name}"

The CoffeeScript Person class compiles to this JavaScript:


var Person;
Person = (function() {
  function Person(name) {
    this.name = name;
  }

  Person.prototype.speak = function() {
    return "My name is " + this.name;
  };

  return Person;

})();

Prototyping in JavaScript is not a simple concept, but CoffeeScript empowers novice developers to use this powerful technique. Programmers with an object oriented background will also think more clearly in CoffeeScript as the syntax is familar. When debugging CoffeeScript, novice JavaScripters will be wading through nice compiled JavaScript and learning good practices rather than fighting with a nest of unrelated methods.

I was quite skeptical about CoffeeScript initially as it simply seemed like a syntactic sugar layer that would impede my learning. Learning JavaScript in detail is necessary to become a expert front end developer, but it turns out that CoffeeScript is a bridge that accelerates the learning curve.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s