Getting a hold of CoffeeScript is easy. There are a number of ways in which you can install it. Firstly, if you’re using a recent version of Ubuntu Linux, you can install it using the built-in package manager. Experience, however tells me that it is likely that the version in your repositories is an older version.
To install it using NPM, run the following command as root:
$ npm install -g coffee-script
The ‘-g’ trigger installs it globally, allowing you to use CoffeeScript anywhere on your computer, and to invoke it from the command line wherever you are. You’re now ready for a great deal of CoffeeScript fun.
I must confess that I might be a little bit biased. Having had the opportunity to spent the past few months writing a great deal of CoffeeScript in my day job, I can attest to how lovely it. Indeed, given my prior exposure to it, I’d heartily encourage novice and journeymen developers to look into as a starting language.
Perhaps one of the most compelling reasons why I am so eager to espouse the virtues of CoffeeScript is because I feel that it has adopted some incredibly innovative language design choices that mandate good software development practices. This means that whatever code you write, odds are good that it will be pretty readable.
In particular, CoffeeScript mandates that you indent all of your code in a sensible, logical manner. Whatever code you produce, it has to follow a logical hierarchy. If it fails to do so, the CoffeeScript compiler yells at you and refuses to execute your code. This will start to feel all too familiar if you have ever written any code in Python.
I’ve observed that CoffeeScript was clearly created with an aim of being really expressive. Syntactically, it’s remarkably similar to plain English, albeit with a few extra parentheses and arrows carefully scattered around the place. An advantage to this is that it becomes trivial to verbally express the flow of your program. Handy if you’re a novice programmer trying to get feedback on your code from someone much more experienced, or working for a software development company that extensively makes use pair programming, such as the one I do.
Further adding to its novice-friendly credentials, in the short period in which it has been in existence, CoffeeScript has managed to develop a rather active and friendly community. Stuck beginners are more than welcome to approach them with questions, and for the most part they’re usually happy to respond. In addition to a strong presence on Stack Overflow, an official website that contains a CoffeeScript interpreter within the page itself and a great many publications about it, you’d be hard pressed to find yourself stuck for too long.
A Beautiful Language
Greg Pollack, the founder of Code School, defines a beautiful programming language as one that allows the developer to get the most stuff done whilst using a minimal amount of code. By this definition, CoffeeScript is a beautiful programming language. From the ground up, it feels just remarkably well designed.
The language itself feels a little bit less weighty, too. Huge swathes of CoffeeScripts bulk is excised. Variables aren’t declared using ‘var’. Parentheses and curly braces are almost as rare as a Bengal tiger. You don’t even need parentheses to pass in parameters to a function. Every function returns something, giving you one less thing to worry about. Mind blowing stuff.
Despite its obvious youth, CoffeeScript has gotten a great deal of attention, and for very good reasons. CoffeeScript was recently included by default in Ruby on Rails, the web framework that powers sites such as Github and Groupon. It’s not just companies which are flocking to it in droves, as developers have started to embrace it and have created a wealth of CoffeeScript plugins, including for Sublime Text 2 and Vim. This means that you don’t have to go without syntax highlighting and code-completion to use the latest, shiniest hipster web technology.
CoffeeScript is a breath of fresh air, and is a welcome addition to any developers toolkit. However, there are little niggles which detract from the experience of developing in it which one hopes will be fixed in later iterations of the product. .
I have since learned that if you compile your code and then pipe it to ‘nl -ba‘, the outputted results are significantly easier to read and contain sensible line numbers.
CoffeeScript reinvents the wheel. There’s no doubt about that. However, it reinvents the wheel, and then turns it into a rhinestoned, bedazzled, sparkly wheel. CoffeeScript is a beautiful wheel indeed. Will you be moving to CoffeeScript for your day-to-day development? Let me know in the comments.