Jeff Mesnil
Weblog · About

Review of JavaScript: The Good Parts

May 27, 2008

I admit: I don't like JavaScript.

I have written and maintained very few scripts and it was a frustrating experience to have them working on several browsers.
However this was many moons ago and I wanted to reevaluate JavaScript after using it in unexpected places (i.e. outside of the browser) like in CouchDB View API or Eclipse Monkey (I already wrote about JMX scripts using Eclipse Monkey).

I was looking for a good book on JavaScript, the language. There are many many books on JavaScript but they focus mainly on JavaScript in the browser and spend thousands pages describing the DOM (please, Messrs. the editors, save the Amazon forest and just print some links to the online DOM documentation...).
I wanted a concise book about writing simple and maintainable code. I also wanted to learn more about the weird syntax constructions spotted when reading non-trivial bits of code, such as processing.js or CouchDB View's map/reduce.

I bought "JavaScript: The Good Parts" on the strength of the author's chapter in "Beautiful Code" and I was not disappointed.
This is exactly the kind of book I'm looking forward to when learning a programming language. It is short (100 pages + 50 pages of appendixes including JSON description) but dense, the sample code are small and meaningful (even the done to death fibonacci and factorial functions used here to explain memoization).
The book does not lose space describing extensively the whole language. It focuses on the subset which is good and proven and do not talk about the edges or the parts which are better forgotten. It really shows how to write code which is both readable, maintainable and elegant.
I'm sure I'll come back to this book every time I read JavaScript code using some peculiarities of the language that I don't understand.

After reading this book, I've got a better understanding of JavaScript and now sees the good (and even beautiful) parts of it. I have a better appreciation for its prototype-based design even if it is hindered by a class-based syntax.
I also find it frustrating that the JavaScript standard library is so useless (no I/O to communicate with the rest of the world). Of course, the library is richer when the code is to run in the browser or on Rhino (gaining access to the whole Java platform) but, by itself, the standard library is very poor compared to what comes bundled with Python or Ruby.

These are critics of the language. For the book, I've got nothing but praises. I recommend it to any programmer wanting to learn more about what is good in JavaScript.

One advice about the code examples: it is much simpler to use Spidermonkey or Rhino than the web browser to run the different scripts and experiment with them interactively.