Review - Javascript: The Good Parts
JavaScript: The Good Parts by Douglas Crockford is a short, dense, humorless outline of a safe subset of JavaScript, targeted at programmers who already hang a few languages on their toolbelt and who find themselves curious about this newfangled "web programming" thing. This book is packed - packed - with key details on the many quirks and foibles of this less-than-perfect language, but ultimately misses its goal of being a strong first stop for new JavaScript developers.
At 100 pages (not including the rather informative appendicies) of 7" by 9", JavaScript: The Good Parts is the thinnest programming book in my library, which is commendable. Crockford, like a true coder, seems to have great skill at avoiding any verbal diahrrea throughout the book, resulting in a clean and clear presentation of pure data. However, this "only the facts" seems to trim away too much. For one, it's completely dry. There is no humor to break up the information, meaning JavaScript: The Good Parts is about as entertaining as a 3-hour PowerPoint presentation on office procedures. But more importantly, the author spends little time elaborating on some of the key issues of the language, where I believe more detailed explainations would help with comprehension.
For example, I'm still a bit unclear about all the nuances of functions in the language. In JavaScript, functions are objects, and are created in function literals. But then there are function statements and function expressions thrown in as well, which have different meaning. There's a heading devoted to each of these subjects, but the examples are so thin - 13 lines total across all these headings, with 5 of them being comments - that I'm still having trouble processing these terms and their differences.
One of the most frustrating oversights in this book is the lack of any look at the Document Object Model (DOM). There is no chapter, sub-heading, or even appendix discussing what the DOM is, or how to use it. I appreciate that Crockford was trying to show that JavaScript can be a beautiful language on its own without needing to depend on DOM modifications, but any serious web development with JavaScript depends on that API. Crockford writes in Chapter 1: "This book touches only very lightly on the DOM. I think writing a Good Parts book about the DOM would be extremely challenging," which clearly demonstrates the author's motives. This isn't a book about practical applications of the language; it's an academic look at its design features. Even though DOM manipulations are critical for web deveopment, Crockford appears to ignore them because they are not well designed.
In general, the examples presented in the book are anemic (even for variable names, which are often a single letter), and mostly only useful for getting syntax right. There are few in-depth examples that show how common design patterns would look in JavaScript. And without any reference to the DOM, most examples don't even have a way to print anything to the screen. A few examples use document.writeln() to print some information, but too many examples end with a one-line comment explaining what the final output would be in theory. For example:
// Capture 3 digits within parens
var oldareacode = /\((\d{3})\)/g;
var p = '(555)666-1212'.replace(oldareacode, '$1-');
// p is '555-666-1212'
Examples rarely stand alone. It's left up to the reader to craft more elaborate examples to experiment with the provided code snippits.
If these complaints have turned you off, then it's because I've chosen to focus on the bad parts. The good parts of The Good Parts speak for themselves, which you can see when you read it for yourself (which you should do!). It may be thin, but it is heavy with great details, and generally presented in a clear, matter-of-fact voice that I wish more books would adopt. It's the least expensive book on O'Reilly's JavaScript bookshelf, and it's over before you have a chance to get too bored with it, so there's no reason not to add it to your library. But if you are looking to learn the language and begin applying it, make sure you pick up a companion book that discusses the DOM, and explains how to implement some common design pattern conventions in JavaScript.
A review copy of JavaScript: The Good Parts was provided by O'Reilly.