Book Review: Learning jQuery Deferreds
I don't often write book reviews here, but in this case I have a connection to the book. My friend Terry Jones was one of the authors of a new O'Reillyprogramming book (you know, the ones with the animal pictures on the covers) which is titled:
I offered to read and provide feedback on a pre-print version of the book (the publishing process all happens on PDFs these days) and I can say it was a great read. In fact, I have the following review of the book:
Concurrent or parallel programming is hard - REALLY hard. Like quantum mechanics, it is one of the few areas where the mark of a true expert is that they admit to NOT clearly understanding the subject.
The "deferred" is an object pattern for handling one piece of the complexity of concurrent code. It helps to bridge the gap between writing things in a linear format as if for a single-threaded computer, and writing a series of triggers that go off when events occur. Those two models are not really compatible, and that can make it quite confusing.
The jQuery library offers a "deferred" object which is deceptively simple: just a handfull of methods. It could all be explained completely in about a page of text (and IS explained that way if you read the docs). But no one who was not already an expert in the use of the "deferred" pattern could possibly use it correctly.
And that is where this book comes in. The text slowly explains what the class offers and how it functions, along with the reasons why each design detail is important. And then it presents a series of exercises of increasing complexity -- all reasonable real-world examples, by the end of which you will fully understand how concurrency can be tamed (partly) with the deferred class. I am a reasonably skilled programmer (20 years experience, at least 15 with concurrent programming) and I found the pace to be about right: everything explained VERY clearly with examples (which is exactly what you want for a tricky subject no matter HOW well you know it).
If you've been using jQuery deferreds for a couple of years now you should probably skip this book -- by this point you may be an expert. But for everyone else who thinks they might be using them, this is a great little tutorial and I recommend it highly.