CoffeeScript or JavaScript?

Recently I played with CoffeeScript a bit. Friends were talking about CoffeeScript and also I read couple of interesting blog posts. Based on my limited experience with it here is my understanding of what is cool and not so cool.


  1. It is much more compact than JavaScript. This translates to up to 1/3 less lines of code than the equivalent JavaScript
  2. Offers the concept of classes – something that is familiar for people coming from the Java world
  3. Insulates you from JavaScript pitfalls like global scope
  4. Some times you can get a performance boost – hard to tell when and by how much
  5. Some compile-time error checking, which helps you to write code with fewer bugs right off the bat

Not so cool:

  1. Hard to debug. You have to debug the generated JavaScript code and from there you have to trace back to the CoffeeScript code
  2. Writing less code can actually be something bad. Anyone remember Perl? And how hard it can be to read Perl code?
  3. Adds another layer of abstraction on top of the browser stack. Adding to this jQuery or other frameworks and you can easily be in a situation where you can put together reasonably complex apps but you have no idea of what is happening under the hood nor how to fix a bug that originates from the frameworks you used
  4. While I understand from why is done the way it was, I still think it would have been nice to have optional data typing

Maybe not so surprisingly , I’ve seen people coming from OOP languages (Java or C#) that totally love CoffeeScript and this is their preferred way to write JavaScript apps.

As I said, I just played with it. So if I misunderstood something or completely missed a point please let me know.

2 thoughts on “CoffeeScript or JavaScript?

  1. That’s a nice summary.

    My main advice to people evaluating CoffeeScript is that you’ll know after a couple days if it’s for you or not. The benefits of CS are entirely subjective, but real–you’ll be working at a higher level of abstraction with less syntax noise.

    Debugging is a bit of a pain at first, but in the not-so-long run this will be less of an issue, as browsers and CS itself start to support source maps.

    CS can be terse, but I find it more readable than Perl. On a syntax level, CS combines Ruby’s flexibility with Python’s clean indentation approach.

    One nice thing about CS is that it transcompiles to relatively readable JS. This prevents you from treating JS too much like a black box, i.e. you still have an idea what’s going on under the hood. Many CS folks claim that writing CS has made them better at JS.

    The popular version of CS is unlikely to incorporate optional data typing any time soon, but there are some interesting forks. Check out Uberscript and

  2. The thing about Perl is that the problem isn’t the terseness, but rather the More Than One Way of Doing It ideology. So in practice you have remember quite a few different syntaxes if you read a lot of Perl code from different sources. A lot of Perl code suffers from the same thing as Javascript code: it is written by people who don’t really know how to program well.

    Coffeescript has definitely sparked my interested and I’ve been experimenting with it a bit. Seems like a good solution to many of Javascripts problems, but the debugging seems to be a pain. I don’t have much of experience with Javascript and I’m debating whether I should actually just use Coffeescript for couple of my own experiments.

Leave a Reply