The Little Book on CoffeeScript – #programming #in #coffeescript #javascript #bookreview

The Little Book on CoffeeScript
By Alex MacCaw (with Jeremy Ashkenas)
(O’Reilly, paperback, list price $8.99; Kindle edition, list price $7.99)

“CoffeeScript (http://coffeescript.org) is a little language that complies down to JavaScript,” says this book’s author. “The syntax is inspired by Ruby and Python, and implements many features from those two languages. This book is designed to help you learn CoffeeScript, understand best practices, and start building awesome client-side applications.”

In just 45 pages, MacCaw does a good job of meeting those goals. It is important, he says, to note that “while CoffeeScript’s syntax is often identical with JavaScript’s, it’s not a superset, and therefore some JavaScript keywords, such as function and var, aren’t permitted, and will throw syntax errors. If you’re writing a CoffeeScript file, it needs to be pure CoffeeScript; you can’t intermingle the two languages.”

He explains that “CoffeeScript uses a straight source-to-source compiler, the idea being that every CoffeeScript statement results in an equivalent JavaScript statement.” So, to program in CoffeeScript, you need to also know JavaScript, so you can debug runtime errors.

Along with showing CoffeeScript’s syntax differences from JavaScript, the book describes CoffeeScript’s features and compares CoffeeScript’s idioms with their JavaScript counterparts.

It also shows how to: (1)  compile CoffeeScript files in static sites, using the Cake build system; (2) structure and deploy CoffeeScript client-side application, using CommonJS modules; and (3) effectively use CoffeeScript’s “ability to fix some of JavaScript’s warts.”

 The book has six chapters, and all are illustrated with code samples:

  • 1. CoffeeScript Syntax
  • 2. CoffeeScript Classes
  • 3. CoffeeScript Idioms
  • 4. Compiling CoffeeScript
  • 5. The Good Parts Describes what CoffeeScript can’t fix about JavaScript and, more importantly, what it can.
  • 6. The Little Conclusion – Discusses “the philosophy behind the changes that CoffeeScript makes to JavaScript”…CoffeeScript aims “to express core JavaScript concepts in as simple and minimal a syntax as we can find for them.”

Alex MacCaw is a Ruby/JavaScript developer and entrepreneur and author of JavaScript Web Applications. Jeremy Ashkenas is the developer of CoffeeScript.

If you are ready to learn CoffeeScript, this nicely focused little book can help you get up to speed quickly on best practices.

#

Si Dunn is a novelist, screenwriter, freelance book reviewer, and former software technical writer and software/hardware QA test specialist. His latest book is a detective novel, Erwin’s Law. His other published works include Jump, a novella, and a book of poetry, plus several short stories, including The 7th Mars Cavalry, all available on Kindle.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: