Javascript: The Good Parts

**** Feb182013

Javascript: The Good Parts is not the book I would recommend to understand the full breadth of what is possible with Javascript; it is not the book I would recommend to a programming novice; nor it is the book I would recommend to someone who’s in a hurry to accomplish a particular task using Javascript. But I would recommend it to either of these groups:

  1. Programmers experienced in other languages. (Hint: this might be you if you know what singletons and closures are.)
  2. Front-end web developers who have used a bit of Javascript here and there, but want to build web apps or any complex client-side functionality. (Hint: this might be you if you’ve used a jQuery plugin, or used code copied and pasted from somewhere on the web.)

Full disclosure: I fall in to the latter group. (And, the fine fellow who recommended the book to me, my friend and Java extraordinaire Ganesh, falls into the former).

Clear but compact

Douglas Crockford writes in a clear and straightforward tone, tinged with a wry humor at times. His code examples and explanations are somewhat dense and certainly require study. He exposes Javascript for what it is: a powerful but flawed tool.

Rather than being a mysterious black box, Javascript is a comprehensible tool created by human beings. Like most tools (especially complex ones) created by human beings, it has some good features and some bad features. If we can learn to exploit the good ones, and avoid or mitigate the effects of the bad ones, we can become better programmers and write better code.

So the author gives us his opinion of what constitutes the good and bad parts of Javascript, and how to code accordingly. I did not find anything particularly controversial (it’s computer code, not politics, after all) but judging by some of the 1- and 2-star reviews on Amazon, some people have taken offense to his approach.

It was somewhat of a revelation to me that I might understand not just how to accomplish this or that using javascript, but more fundamentally how the language of Javascript works. Furthermore, I felt reassured that I am not idiot for not immediately comprehending everything about the language:

“This book is small, but it is dense…Don’t be discouraged if it takes multiple readings to get it” (p. xi). “Programming is a difficult business. It should never be undertaken in ignorance” (p. 2).

Guidelines and style, not snippets

You will not find a solution in this book for implementing a live search box using ajax, or how to create an animated slideshow. What you will find are some guidelines for how to be a better Javascript programmer. The author reminds us that we are writing code not just to accomplish the task at hand, but to allow future programmers (possibly even our future selves) to be confident in adapting the code to accomplish future tasks. Thus, readability and “expressiveness” (a term the author uses often) are more valuable than terseness and cleverness:

“If a program is expressed well, then we have the best chance of being able to understand it so that it can be successfully modified or repaired…It turns out that style matters in programming for the same reason that it matters in writing. It makes for better reading.” (pp. 94-95)

Regex and Railroads

Chapter 7, on regular expressions, seems a little out of place, since regular expressions are not a feature exclusive to javascript. Furthermore, while I’ve used them (and struggled mightily to write my own or understand existing ones) it has only been occasionally; I am not sure why they merit an entire chapter in this book. That said, as broken down by Mr. Crockford, the consituent parts and assembled whole of regular expressions are quite understandable, and the chapter serves as a tidy introduction to the topic.

A minor complaint I have about this book is regarding the railroad diagrams. The author uses these to explain the “grammar” of Javascript, but for me a selection of apt examples would be easier to understand. However, perhaps people who have learned other programming languages are accustomed to seeing this format.


Javascript: The Good Parts is an excellent book on Javascript for the right audience. Namely, those who want to have a more thorough understanding of how the language itself works, and what its best and worst features are.

Respond to this review

Author(s)Douglas Crockford

No comments yet…Be the first!

Comments are closed for this article.