Dropbox prefers the simplified syntax of CoffeeScript

Sep 14, 2012 12:03 GMT  ·  By

JavaScript is the heart of the web and it's a powerful language especially now that all browsers have fast or very fast JavaScript engines. But it is close to two decades old and it was created in somewhat of a hurry. Some people think JavaScript can be better and some of those people created CoffeeScript.

CoffeeScript isn't necessarily a new language, it is just another way of writing JavaScript code. Anything written in CoffeeScript is compiled, more like converted, into JavaScript which is then run in the browser natively.

The people at Dropbox are, apparently, big fans or they became big fans as they rewrote the entire site in CoffeeScript over one week and had it running live on the site soon after.

At this point, the site is entirely written in CoffeeScript, which is then automatically converted into JavaScript which is minified, gzipped and published on the site.

Dropbox has a long post on its tech blog describing the entire process, some of the issues they overcome and debunking some of the misconceptions around CoffeeScript.

Right now, all web code is written in CoffeeScript at Dropbox and it has been so for some months. After the first conversion, which took one week, Dropbox compared the codebase to get an idea of the improvements.

The Dropbox site went from 23,437 lines of code, in JavaScript, to 18,417 in CoffeeScript, a 21 percent reduction. Much of those lines were actually just unneeded syntax, but it was a big improvement anyway. The code also went from 75,334 tokens to 66,058.

Needless to say, Dropbox is a big fan of CoffeeScript and highly recommends it. Granted, as the devs will admit themselves, their preference for Python, used for all the heavy-duty backend stuff and which is similar in syntax to CoffeeScript, may have something to do with their love of CoffeeScript.