Skip to main content

Mike Kreuzer

Coffee break

20 November 2013

I've become quite enamoured with CoffeeScript, one of the languages competing to rescue us from JavaScript, and JavaScript from itself. I've only been playing with it for a few hours so far, but so far so good.

CoffeeScript seems to be in much wider use than some of its competitors and unlike Dart or TypeScript it isn't tied to a wider agenda, and finally, though I'm unlikely to start using the feature any time soon, the idea of literate coding strikes a chord with me.


You can get CoffeeScript to run independently, but I also wanted to look into Node (again), so I set that up too. Installing Node took hours and two attempts (again). I'm not sure why I can never remember, but every time I install node — admittedly that's infrequently, but even so…— every time I waste an hour or two trawling through the howtos scattered across the internetz, most of which are wrong.

To shortcut this process next time: Homebrew is your friend here. There's no need to go all super-user and/or to destroy the permissions architecture on your machine, neither Node nor CoffeeScript require sudo to install.

ruby -e "$(curl -fsSL"
brew doctor
brew install node
npm install -g coffee-script

If like me you forget about Homebrew till late in the day you can also insert much swearing and deleting leftover bits of Node from /usr/local/lib/ and running 'brew link node' a couple of times in between steps two & three, but that's all optional.

What's my motivation?

JavaScript is by far & away the ugliest, cruftiest & most past its use by date of any of the major programming languages. The whole prototype-based mess should have been put up against the wall a long time ago. And I have some JavaScript coding to do.

CoffeeScript compiles into JavaScript, so suddenly I can have classes, and reasonable certainty my variables really are as local as they appear to be, and maybe less heartache.

Plus there's this blog. In under a week the Liquid tags in Jekyll have started to annoy me, & little things like that extra white space at the start of that code block earlier on this page grate, as does the propensity of Liquid/ERB/etc users to insert logic into their templates.

It took a fun but long-ish evening to set up the logic for the index and archive pages on this site independently of its layout, and to get most but not all of the things I wanted to work working — tags for example are still missing, using Jade is a pain, and the RSS generator in Ruby is rubbish — still, I don't mind Jekyll overall.

I looked very briefly at DocPad [link no longer works] & Wintersmith. Sadly Eco users (Eco's the CoffeeScript version of ERB), and even Jade users seem to tend to do the same thing in terms of mixing logic into their layout templates. The first file I looked at in Wintersmith was the archive page template and…

//- this logic should be moved to a view at some point

CoffeeScript substantially lowered the cost of investigating Node for me. I didn't find anything compelling to make me move on just yet, but it was a fun trip and I may yet change my mind.