I’ve never been a particular fan of Javascript. It has always been a ‘necessary evil’, completely unavoidable if intending to do anything client-side in the browser.

Starting from PHP, it wasn’t so bad, but then I began to get spoiled by whitespace-structured languages like Python, I revelled in not being lost in a constant sea of curly brackets and semi-colons.

With that in mind, I decided to try a Javascript pre-processor I had heard a little about (CoffeeScript). I had avoided them in the past, because the sites I had worked on tended to be server side projects, so the extra overhead and pipelining required to get it all running seemed, for my particular uses, overkill.

I have been building this site, however, using Jekyll, a static site generator, and so, since the process there involved a single build, serve statically model, that overhead no longer seemed relevant.

And oh, have I been missing out.

Not only do I get an indentation delineated structure, and newlines ending statements, but, among so many other great features, (mostly ‘stolen’ from other languages), my absolute favourite feature of Python: The list comprehension!

Never will I have to suffer having to write (Supposing I want the list ):

var x, i, results;
results = [];
for (x = i = 0; i <= 10; x = ++i) {
    results.push(x ** 2);
}
// results == [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

when

coffee_results = ( x**2 for x in [0..10] )
# coffee_results == [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

Huzzah!