Wednesday, September 11, 2013

In Defense of #CoffeeScript

@coryio - Cory McIlroy

This is an open response to a recent challenge discussion post by a member (you know who you are) who referred to CoffeeScipt as an "esoteric language". I too used to be a CoffeeScript hater. While I'm not a true disciple (yet?), I do want to take a few minutes to provide three arguments for why CoffeeScript should be tolerated, if not embraced, as a language in our community.

#1 It really makes "top level" application code easier to read. In the convention over configuration pattern used in many of our current node.js projects, we all spend plenty of time reading and editing a few high level bits of JavaScript that define the overall application. Bottom line: CoffeeScript makes these files easier to read quickly.

#2 It makes you a better JavaScript developer. Go read the "Everything is an Expression" and "Function Binding" sections of the CoffeeScript docs. Then get your hands on some CoffeeScript code, compile it to JavaScript, and spend 10 minutes comparing the original to the compiled version. My bet is you'll feel like you learned something from those two exercises.

#3 To quote their Golden Rule: "It's just JavaScript". CoffeeScript compiles to easy-to-read JavaScript and you can call JavaScript from CoffeeScript! As I mentioned earlier, I'm not a CoffeeScript purist by any means. I believe that with even the tiniest bit of care, the two languages can be used clearly and effectively within the same project. If you see a challenge come up that has used CoffeeScript in the past, don't write it off as "not for you". Sure, you may have to write a few lines of CoffeeScript, but you can also feel free to implement chunks of logic in js.

No comments:

Post a Comment