Ramblings of a Mad Deanius

A stream-of-thought blog on tech, music and fitness

Promises and Futures - the Tardises of JavaScript

I do like to wax eloquent from time to time on a coding concept that gives me warm fuzzies.

Other times, it’s been done so well for me already that I have to tip my hat and give credit where credit is due. This is one such time: I present to you Jose on Code’s Promises Article

The money quote: “Promises are about … providing a direct correspondence between synchronous functions and asynchronous functions.”

They are a concept which – once grokked, allow you to break the standard falling-dominoes metaphor of coding, jumping effortlessly between the present, the future, back to the present and of course Back to the Future (oh yes, i did)

In the short future (that’s a Promises/Futures reference), I will detail how I used jQuery’s Deferred framework to clean up some code that had been written in the uglier callback style. I have to get the code cleaned up and on gists, but it’ll be less instructive I think than Jose’s link.

They are not going away anytime soon, and frankly they’re so plainly an improvement that until they’re beaten by another standard, they’re the only game in town, so you may as well learn them. I’m certainly glad I did.

Comments