Relevance Review #8: Pragmatic Ajax

Pragmatic Ajax, by Justin Gehtland, Ben Galbraith, and Dion Almaer

Reviewer's Disclosure: I (Stu) own a company with Justin, and am very good friends with Ben and Dion.

Quick Summary:Strong introduction to Ajax; excellent comparisons building simple Ajax functionality with a variety of the best client and server side tools.

I would divide Pragmatic Ajax into five parts:

  1. Introduction and Background (Chapters 1-4)
  2. The Client Side (Chapters 5-7, with a few asides)
  3. Intermediate Concepts (Chapters 8-10)
  4. The Server Side (Chapters 11-15)
  5. The Future (Chapter 16)
Each part is reviewed below.

The introduction and background chapters are strong. This material is similar to material in every other Ajax books, with a couple of distinguishing features. Chapter Two builds a Google-Maps-like application. While I don't think most developers will use Ajax to build mapping applications, this is just cool. The other, more important feature is the choice of a very simple example: the Zip code lookup. Chapter 3 introduces a form that automatically populates a city and state as the user enters a Zip code. I like this example (and use it myself when training) because the basic code is incredibly simple. As a reader you can focus on the Ajaxy parts, without getting bogged down in the complexity of the sample itself. Rather than introduce a ton of new examples as the book goes on, the authors re-implement this example about a dozen times throughout the book, comparing and contrasting wire formats, client libraries, and server libraries.

The client side chapters build the Zip code example several times. Along the way they introduce client-side helper libraries, remoting options, validation, bookmark and back button support, visual effects, progress indicators, and update indicators. These chapters are the most important part of the book, in that they (a) make a strong case for introducing libraries and (b) choose good libraries to introduce. The examples are built using Prototype/Scriptaculous and Dojo. When you consider both code quality and integration with server side technologies, these are among the most important libraries out there. Do not build Ajax applications in raw JavaScript!

The intermediate chapters answer the question "I can build a basic Ajax application, what happens now?" Chapter 8 introduces a variety of tools for debugging Ajax applications inside various browsers, including logging, DOM inspection, and step debugging. Everyone should learn these debugging tools--I am constantly surprised to discover developers troubleshooting their Ajax apps with nothing more than their browser and intuition. Chapter 8 also sneaks in yet another cool Ajax framework, MochiKit. Chapter 9 shows how to make your Ajax application "degradable," i.e. functional in non-Ajax browsers. Chapter 10 introduces JSON and JSON-RPC as an alternative to XML.

The server-side chapters compare and contrast different server-side choices for Ajax: PHP (Sajax and XOAD), ASP.NET (Atlas and Ajax.NET), Java (with DWR), and Rails. The authors made three smart choices that make these survey chapters work better than similar chapters in other books:

  1. These are the right four choices to cover
  2. All the examples are the same Zip code lookup, so you can focus on the language and tool differences
  3. You don't have to wade through pages of setup instructions unrelated to Ajax

The futures chapter covers several emerging technologies and standards that haven't hit their stride yet, e.g. E4X, Canvas, and SVG. At least one of these technologies will be very important in the next generation of Ajax apps, but I am not sure which. :-)

Last Word:Pragmatic Ajax and Ajax in Action (reviewed here) complement one another nicely. As of today (May 3, 2006) I believe these are the two must-have books for Ajax developers.

Get In Touch