CoffeeScript Sucks

Or: How I learned to stop worrying and love the drip.

Javascript and I didn’t get off to a good start. I liked to think that it wasn’t about me, and odds are that it wasn’t: outside of popping up annoying windows and even more annoying alerts, infantile javascript simply wasn’t that useful. Fast-forward a few years, add a few) game-changing developments, and javascript now lies at the heart of much of my client- and server-side development. So the first time I encountered CoffeeScript, I tried to swallow my misgivings and give it an honest shot.

It didn’t work.

Young coffee-script was cute, but in its infantile stage the energy needed to bend it to practical ends far outweighed any savings it seemed ready to provide. That was 2011, and oh! How wrong I was.

For a variety of reasons 2012 was year Arabica. Fantastic new tools for developing and integrating coffeescript into production code emerged; community (and library) support expanded to welcome the new dialect to the greater javascript family; and on a personal note, both my laziness and wrists have thrived under terse, consistent syntax. I’ve drunk the coffee.

For the prosecution, the case against CoffeeScript usually come down to four points:

  1. Coffeescript is hard to read
  2. It requires an extra compile step
  3. It’s hard to debug
  4. Javascript ain’t broken

1. Coffeescript is hard to read.

CoffeeScript is designed so that nearly anything can be used as an expression–a feature that’s as handy as it is an enormous enabler of bewildering code. I doubt I’m alone in confusing the in comprehension (iterate over array) with of (objects), and I’m pretty sure there are clearer ways to express conditions than:

doctorGoes = if oranges == apples then true else fruit == 'apple'

Still, many of these expressions have their own utility, and CoffeeScript is far from alone in allowing developers to write obfuscated code.

2. It requires an extra compile step

It’s true: browsers don’t speak coffeescript. But neither do they speak SASS, LESS, or minify scripts on their own. In this day and age, it’s hard to imagine a build process that doesn’t involve at least one layer of asset preparation. Coffeescript tasks for grunt–or better yet, [Yeoman]–turn compilation from a persistent annoyance into an utterly forgettable experience.

3. It’s hard to debug

Even with compilation reduced to a non-issue, there’s still the case
Isn’t this a great time to start considering how preemptive tests might help reduce the need for reactive debugging?

4. Javascript ain’t broken

There’s an argument circling in certain neo-revivalist corners that coffeescript does Javascript can’t already do. To the letter of the law, truth. CoffeeScript is just Javascript. But beneath the surface–just barely beneath the surface–it becomes something more.

class Reason
  because: (@thatsWhy) -> @

whyCoffeeScript = new Reason
whyCoffeeScript.because("It's awesome").thatsWhy

That’s right. Just defined an extensible function, added an accessor to its prototype, and chained it all together quicker than Tim Horton can dial up a cup of joe.

Hey, I'm RJ! For more learnings about software and management, find me @rjzaworski or sign up for my semi-regular newsletter.

Let’s keep in touch

Send me timely updates on software, product, and process.