JavaScript is a quirky, peculiar language – and yet it shines as a fun, productive language, especially when you add jQuery or Dojo to the mix.  CoffeeScript caught my eye when it first started appearing on my favorite web development blogs; any tool that can fix the oddities of JavaScript programming gets my full attention, so I was excited to read this book.  In retrospect, I’m very glad I picked up this short book.

Alex nicely covers the use and syntax of CoffeeScript, starting with variable and function declarations, arrays, and logic branching statements (most books on a language begin with these building blocks, so no surprise there).  This new language results in significant alterations to the syntax and structure of JavaScript; CoffeeScript bears a strong resemblance to Python, especially in its use of whitespace and indentation, as opposed to the curly braces typically used in JavaScript and other C-style languages.  If you’re looking for a library that simply enhances JS, as jQuery does, then you might not like CoffeeScript – but I think it’s definitely worth learning the alternative syntax of this small new language.  I was pleasantly surprised that jQuery and CoffeeScript can easily be used together, effectively complementing each other.

I found chapters 2, 3, and 4 to be the most immediately useful sections in the book.  Classes are discussed in chapter two – creating them revolves entirely around the “class” keyword, which is logical enough.  You can create instances of the class with the “new” keyword, and both static properties and instance properties can be included in a given CoffeeScript class.  There is also an “extends” keyword for inheritance, and an easy way to create a constructor method.

Chapter 3 starts with the CoffeeScript versions of ECMAScript 5 additions.  The “each” function is more efficient than the ES5 equivalents, “forEach” and “map”, due to the way the CoffeeScript code is compiled into JS.  Some time is also spent describing the “natural language” style of logical comparisons, using “and”, “or”, and “is” instead of “&&”, “||”, and “==”.

Chapter 4 is really cool, and answers a lot of practical questions about implementation.  Cake is discussed as a way to compile CoffeeScript; later, the author outlines using Node (server-side JS) to compile the CoffeeScript when the page is requested.  Templating systems are also discussed in this chapter, and it’s fascinating stuff.  The chapter ends with a brief explanation of setting up a Node server on Heroku’s Cedar stack.

Overall, I’m very glad I read this book.  I’ve read some great tech reference books, and I’ve read some awful ones – this book is definitely one of the better ones.

I should disclose that I received a free e-book copy of this reference book from O’Reilly, in exchange for a review.  I participate in the O’Reilly Blogger Review Program.

You can find this book in the O’Reilly Online Catalog at: http://shop.oreilly.com/product/0636920024309.do