Coffeescript vs. Javascript: Dog eat Dog


I’m happy to say that I’m now an official los techies “techie”!  Thanks to Chris Missal and all the other amazingly smart people who let me join the Los Techies crew.  Without further ado, this article is going to focus on the pros and cons of javascript vs coffeescript.

The Case against Javascript

Javascript has a bad reputation of being a flaky scripting language, because let’s face it, that’s exactly how it started out.  There are a number of let’s say, quirks, in the language that make most developers cringe:

  • Strange type coercision and overloading of +
  • Strange results for equality testing == or ===, != and !==
  • Prototypal inheritance vs. class based object orientation
  • Noisy syntax, lots of curly braces, function keywords, and semicolons
  • Global variables are as easy a missing a var statement
  • Lack of any sort of design aesthetic
  • Lots of bad javascript progammers (think graphic designers)
  • Lots of bad javascript code (think code that a graphic designer would write)
  • Hundreds of implementations for every browser, version and other javascript dependent platform (and yes, some of them are buggy)

Now those last three are more a reflection of the javascript ecosystem than the language design, but they are worth a mention, because they contribute to javascript’s overall poor repuation.

There’s actually some great stuff about Javascript

While javascript may look gnarly on the outside, there are actually some pretty nice features from a semantic standpoint:

  • Awesomely dynamic (basically you can do anything you want, type safety and common sense be damned)
  • Top-notch functional programming
  • Largest community of developers
  • Largest install base on the planet
  • No corporate ownership of the standard
  • Sophisticated javascript runtimes (most modern browsers, node.js etc)

Coffeescript:  It’s Better than Javascript right?

A few years ago, coffeescript jumped onto the scene as an alternative to straight-up javascript. (If you want to take a closer peak at the syntax, then I advise you checkout their site, coffeescript.org.)

CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart. CoffeeScript is an attempt to expose the good parts of JavaScript in a simple way.

What a novel idea!?  A precompiled language that fixes all of the nastiness and awkwardness of the javascript language.

Well, it turns out that it’s not that simple.  Here’s an excellent rant/explanation of why coffeescript is not so great.

The Subjective Argument against Coffeescript

The subjective argument against coffeescript can be summed up pretty easily:

Do you like C-style syntax or Ruby/Python-style syntax?

Coffeescript was designed in the vein of Python and Ruby, so if you hate those languages then you will probably hate coffeescript.  As far as programming languages go, I believe that a developer will usually be more productive in the language that they like programming in.  This may seem like a no-brainer, but there are quite a few articles out there trying to argue the objective truth of and vs &&.

The Hard Objective Arguments against Coffeescript

Here are what I consider the most pertinent arguments against coffeescript.

  • Added debugging complexity
  • Added compile complexity
  • Smaller development community

How to Decide which language for your Project

I’ve worked on large projects in both javascript and coffeescript, and guess what?  You can build an application in either one, and your decision of javascript or coffeescript is not going to make or break you.

If you are working on a project by yourself, then I would pick whichever language you prefer working in.  It’s totally subjective, but you are going to be more productive coding in a language that you like coding in vs. one that you hate coding in.

Now, for the tricky part.  What if you’re working on a team?

Coffeescript ate my Homework

This is where coffeescript can be a huge problem.  If you are working with a tight group of skilled engineers, and you decide to work in coffeescript, and everyone is on board, then my opinion is that you might very well end up being more productive.  Especially with programmers that have a Ruby or Python background.

However, for projects that have a revolving team of contractors or that have junior developers that hardly understand the semantics of javascript to begin with, then I would say watch out!

This may seem paradoxical, but I think part of the problem comes back to the debugging cycle.  Debugging is a critical part of learning a new language, and for someone with a good javascript background, the coffeescript debugging problem shouldn’t be that much of an issue.  However, for a noob, it can be a killer.  They don’t grasp if their mistakes are part of coffeescript or javascript which leads to major time sinks on very mundane syntax errors.

In short… it depends 🙂