Back To The Futures (JavaScript)




Back to the Futures (JavaScript)

20 February 2018


Added 01-Jan-1970

Asynchronous programming in JavaScript has been on an exciting journey over the life of the language. We've always needed to avoid blocking UI to do computation, and various solutions have been explored over the years - events, callbacks, Observables, Promises...

It's likely that you've encountered Promises if you've been writing any JavaScript in the last few years, and with native Promise implementations in NodeJS and all modern browsers, combined with the introduction of async/await in ES2017, they've never been more ubiquitous or useful.

It may seem like a crazy time to be looking for alternatives when Promises have so clearly 'won' the async battle, but I think there is a lot to be learned from an older technique from functional programming. A technique that is lazy (we functional folk consider this a good thing), cancellable, and conforms to the monadic interface, opening up a world of interactions with other useful functional techniques. I think it's time to try Promise's algebraic cousin, the Future.