Book Review: JavaScript Promises Essentials (PACKT Publishing)

With ECMAScript 6 on the horizon of becoming the JavaScript standard, JavaScript Promises Essentials (PACKT), by Rami Sarieddine, proves to be a timely release.  A relatively quick read, though technical and not always easy, at 90 pages–which includes the preface, appendix and index–this is more of a small booklet and may cause the a consumer to take pause if thinking of buying the hard-copy version at over $20 (the electronic version is going for $9.99).  (For disclosure purposes, PACKT gave me access to a free electronic version of this book in exchange for posting this review on Amazon and  If you can get by the price, though, I found the content of the book to be generally quite good with a couple annoyances I’ll get into shortly.

My personal introduction to the promise pattern came a couple years ago when I started looking into Windows 8 app development with WinJS, which includes an intuitive implementation of promises that conforms to the Promises/A standard.  With my positive introduction to this pattern–which is much more intuitive manner of handling async responses by chaining promise objects and passing your callbacks into the promises then method, rather than nesting your callbacks–I then started looking into Deferreds in jQuery.  In all honesty, though, I find I rarely use them as I find the jQuery implementation to be not at all intuitive.  So it is with this background, I dove into Sarieddine’s work.

There is a lot to like in this book.  He does a good job explaining how the Promises/A+ pattern works, how it differs from the Promises/A standard, where it is in terms of standardization with ECMAScript 6 and current browser support, what some of the libraries are out these that will polyfill support in the interim, and how error handling is done.  Additionally, he steps us a through an implementation of a basic Promises/A+ compliant promises object model.  I often times found myself saying I wish it would explain such-and-such, and within a few pages it would.  One such instance was I wished he would show us how to convert a jQuery Deferred into a promise, and then he did so with the Q and Promise libraries (p. 26).

My quibbles with the content are small-ish.  The first is the limited discussion about jQuery Deferreds, which doesn’t go much beyond saying they don’t follow a standard and quickly demonstrating how to convert them to promises with existing libraries.  Given the prominence of jQuery out in the wild, it deserves a fuller discussion even if not compliant with how standards are panning out.  Speaking of prominence, there is an entire chapter devoted to promises in WinJS, which does seem a bit much given WinJS hasn’t exactly taken the JavaScript world by storm.  But hey, that’s where I first encountered them (though I’ve chosen a lot of losers in my life with my experiments).  And if you happen to use WinJS, well, here you go.

The book also tends not to use practical examples, but rather the examples tend to be functions that return messages of the alert(“Hello there”) variety.  One in-depth practical example, maybe creating a mash-up calling into an API would, perhaps, help drill home how useful promises are, rather than being left simply with theoretical promise.  This likely would make a better chapter than the chapter devoted to WinJS.

And, while I hate to be that proverbial guy, the editing job on the book needs some serious work.  Throughout it appears auto-capitalization is used on function names if they are the first word in a sentence.  With promises, where the methods have name like “then”, this can make for a confusing read as on first read you think it’s the word “Then,” when it’s actually the method “then.”

But having said that, there is a lot of useful content in here, and you will come out of this with a solid understanding of promises and the current state of them.  Worth the read, but debatable if it’s worth the price.

Amazon Rating: 4 out of 5 stars


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s