CoffeeScript: Accelerated JavaScript Development – #bookreview #programming

CoffeeScript: Accelerated JavaScript Development
By Trevor Burnham
(Pragmatic Bookshelf, $29.00, paperback)

JavaScript was thrown together in 10 days and “was never meant to be the most important programming language in the world,” says Trevor Burnham, a web developer and founder of DataBraid, a startup focused on “developing data analysis and visualization tools.”

Yet, JavaScript was “understood by all major browsers,” despite their numerous differences, and it quickly became the “lingua franca of the Web,” he says in his well-written new book.

JavaScript also became a headache for many programmers struggling to learn it well enough to provide support and develop new applications.

“JavaScript is vast…[and] offers many of the best features of functional languages while retaining the feel of an imperative language,” Burnham notes. “This subtle power is one of the reasons that JavaScript tends to confound newcomers: functions can be passed around as arguments and returned from other functions; objects can be passed around as arguments and returned from other functions; objects can have new methods added at any time; in short, functions are first-class objects.”

Unfortunately, “JavaScript doesn’t have a standard interpreter,” he adds. “Instead, hundreds of browsers and server-side frameworks run JavaScript in their own way. Debugging cross-platform inconsistencies is a huge pain.”

Enter CoffeeScript, first released on Christmas Day, 2009 as “JavaScript’s less ostentatious kid brother.”

Coding in CoffeeScript requires fewer characters and fewer lines. And “the compiler tries its best to generate JavaScript Lint-compliant output, which is a great filter for common human errors and nonstandard idioms,” Burnham writes.

Another benefit: “CoffeeScript code and JavaScript code can interact freely,” he notes.

His book, aimed at CoffeeScript newcomers, assumes you have at least a little knowledge of JavaScript. But you don’t have to be a JavaScript Ninja, he assures.

He starts at the classic “Hello, world” level of CoffeeScript, including installing the CoffeeScript compiler, deciding which text editors are best, and learning how to write and debug simple CoffeeScript code.

From there, he moves quickly into showing you how to put CoffeeScript to work and develop a simple multiplayer game.

There are several different ways to run CoffeeScript, and there are different requirements, depending on whether your machine is Mac, Windows or Linux. Burnham describes these in his text and in an appendix, and he gives links to more information.

He also shows how to use a browser-based compiler for developing his book’s example application. But he does not recommend using the browser-based compiler for production work.

His book has six chapters and four appendices:

  • Chapter 1 – Getting Started
  • Chapter 2 – Functions, Scope, and Context
  • Chapter 3 – Collections and Iteration
  • Chapter 4 – Modules and Classes
  • Chapter 5 – Web Interactivity with jQuery
  • Chapter 6 – Server-Side Apps with Node.js
  • A1 – Answers to Exercises
  • A2 - Ways of Running CoffeeScript
  • A3 – Cheat Sheet for JavaScripters
  • A4 – Bibliography

CoffeeScript: Accelerated JavaScript Development offers a focused blend of examples and exercises to help speed up basic competency with CoffeeScript. In learning how to build the multiplayer game application, you use CoffeeScript to write both the client (with jQuery) and the server (with Node.js).

Since CoffeeScript and JavaScript are intertwined, you also can gain a better understanding of JavaScript by learning to code in CoffeeScript, ” Burnham promises.

In a foreword to the book, CoffeeScript’s creator, Jeremy Ashkenas, hails Burnham’s work as “a gentle introduction to CoffeeScript led by an expert guide.”

It lives up to that good billing, with many short code examples and many short tutorials and exercises that can lead quickly to building both a working app and a working understanding of CoffeeScript.

Si Dunn

About these ads

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s