My Book reviews /

The Little Book on CoffeeScript

Title The Little Book on CoffeeScript
Authors Alex MacCaw
Publisher O'Reilly Media
Date 2012-01-31
Pages 62
ISBN 1449321054

This is one of the best programming books I have read in years, due to a number of reasons:

  • It is small, only 60 pages
  • It is free, but I got my copy though OReilly blogger reivew program
  • It is well written. The narration goes from simple to complex

So what is this all about? Javascript is easy to learn, and this is what its creators aimed at. But as a result you get lots of headache when you try to use some advanced features such as classes, inheritance, etc. Are those really advanced features? In those days when Javascript was designed, they were. So, Javascript is simply showing its age, and the time to give it a major overhaul has come.

Recently, people have come up with many nice languages such as Python and Ruby which share many common features. Nobody claims they are easy to learn, but they are easy to use. So, the initial goal of building an easy language has been achieved. A new set of language constructs and idioms has been adopted (such as using indentation instead of brackets, arrow instead of function keyword, ranges, comprehensions, etc.). A new generation of developers expects iterators, maps, ranges, closures to be standard features of any programming languages. To most C++ programmers those look like quite advanved features provided by libraries such as STL. But Java revolution has happened: people got used to this syntactic expressiveness.

Coffeescript adds syntactic sugar to Javascript, bringing its language constructs on par with those of Python and Ruby. The good thing is that it compiles down to Javascript, so you can paste the output in existing web pages without any problem. No server support or library is necessary. You can even use interactive compiler that converts your Coffeescript into Javascript on the go.

The book is nicely written. Each chapter is dedicated to a certain aspect of the language: classes, idioms, the good parts, etc. Each chapter starts with a few simple examples, but it concludes with some really tricky stuff which can keep your attention for several minutues. For example, the chapter about classes mentions Mixins in the end, which is essentially a way to implement abstract classes (interfaces) in Javascript. Still, some people claim that CoffeeScript introduces new problems while trying to fix Javascript issues. This is why some language hackers added even more sugar to CoffeeScript. One such attempt is called Coco, look at all the new syntactic constructs it adds. They are awesome! So concise and powerful