Wednesday, February 2, 2011

Pragmatic Guide to JavaScript

Author: Christophe Porteneuve
Format: Paperback, 150 pages
Publisher: Pragmatic Bookshelf; 1st edition (November 22, 2010)
ISBN-10: 1934356670
ISBN-13: 978-1934356678

So there are just billions of JavaScript books on the market and if you are interested in this language, or learning more about this language, you probably own several. Why would you want to buy the Pragmatic version? What sets it apart from the rest of the herd? What does it bring to the table?

Good questions. But can Porteneuve's book provide the answers?

According to the blurb on the back cover, the book will get you up to speed quickly and painlessly with the 35 key JavaScript tasks you need to know. Task-oriented is good. You can't learn to use a programming language without writing the programming language. I am concerned about the phrase the 35 key JavaScript tasks you need to know. How does anyone know which tasks I need?

Often, my favorite part of a book such as this is the Who is this book for section. Here is where you'll find the "official" mission of the book and sometimes where you'll find the inconsistency between the book's stated purpose and how it's actually written. Here's the first sentence:
This book is not really intended to teach you "JavaScript the language".
What? That's not the impression I got from the back cover. As the "Who is this book not for section continues, it says that the language is pretty easy on its own so, if you know any programming at all, learning the basics (loops, variables, and so on) isn't much of a chore. The book even recommends the "JavaScript Core skills" section of Opera's Web Standards Curriculum.

So who really should buy this book?

Apparently, people who already have a smattering of JavaScript knowledge (or more), but who need a set of specific solutions to common JavaScript tasks. The tasks are collected into six different parts in the book, including Pure JavaScript, The DOM, Events, and Timers, UI Tricks, and more.

Each task is generally presented in a two-page spread, with the description of the task on the left and the code samples on the right. I say code "samples", because the "finished product" isn't presented on a silver platter for the reader, hence the need to not just know, but to be familiar with programming in general and JavaScript in specific right at the onset. Thus, you can think of this book as not for the JavaScript beginner, but as the next step in a JavaScript coder's progress in learning to apply practical solutions to JavaScript problems.

This is a good thing, since most beginner's JavaScript books focus on teaching the language but don't really teach you what to do with it. It would be really cool if a publisher like Pragmatic would publish a series of books on a language, starting with a complete beginner's primer, and then producing subsequent books aimed at different skill levels and applications for the language.

JavaScript really isn't just about the language. Except for very minor tasks, in production, you almost always are using a framework such as jQuery, Dojo, or MooTools. Although this book advertises itself as "framework agnostic", it (and the author, I suppose) tends to favor ProtoType as a framework. That said, it's not an exclusive ProtoType tutorial and does offer creative solutions to what are considered common problems.

Every book has a website, and this one is no exception. The book's official site is, where you can access the sample code, review the errata, and participate in forum conversations about the book's contents (though, there are only three threads, the most recent being November 2010 as of this writing).

Like all books that present specific tasks and solutions, Pragmatic Guide to JavaScript is limited by its own parameters. That is, it won't tell you how to solve problems beyond the 35 tasks presented in the book. However, the book also helps you learn different ways (hopefully) to solve problems you may have already confronted or with which you are currently struggling. Before buying, it's probably best to scan the table of contents and see if there are enough of the kinds of tasks that you need to explore. If so, pick up a copy and have at it...and have fun.