The Honeymoon

When I first got my hands on CoffeeScript, I fell in love. It abstracted away a ton of boilerplate JavaScript code and handled a large number of common JavaScript "idioms." Naturally, I began to replace all of my JavaScript usage with CoffeeScript—and life was good.

Annoyingly trivial example

if (str && str.slice(-1) === '?') {  
    // Handle the question


if str?[-1..] is '?'  
    # Handle the question

The Falling Out

CoffeeScript made my JavaScript life simple for a time, and it was good. I wasn't undertaking any major JavaScript projects, so my CoffeeScript usage was replacing very basic JavaScript. Fast-forward a year or so: my employer saddles me with a rather large application that I ended up building using AngularJS and CoffeeScript. As the controllers and services began to grow, product requirements morphed and designs changes, I found myself longing for help with refactoring. I did a lot of jumping around between files to refresh my memory on inputs to functions, and refactoring resulted in some unsavory regular expressions.

This is when I came to appreciate TypeScript. I would have cut down on the number of tests, saved myself time debugging stupid errors, made refactoring much simpler and <insert 7,000 other reasons for choosing to leverage static type checking> had I started this project in TypeScript.

The Takeaway

I'm sure this sounds like a love song to static typing (of which I am generally a huge fan), but I do find that static typing will save you a lot of headaches at the cost of writing some slightly more verbose code. I miss a number of the nice shortcuts CoffeeScript provides now that I have picked up TypeScript, but saving myself a few keystrokes now is not worth having to go through the hoops when a projects gets enormous. That's not to say I have ditched CoffeeScript though; it still has a place in my tool belt. I still default to CoffeeScript on small, quick scripts where the gains from static typing would be questionable at best.

Now don't get me started on Ruby...