Ask HN: Is JavaScript abandoning Promises
Recently in a technical screening, a senior engineer asked me what I thought about Javascript moving away from Promises in favor of Observables. I replied that I didn't know that Javascript was moving away from Promises, since Promises are part of the ES6 spec.
In general, I was blindsided by this. So my 2 questions are:
1. Is Javascript truly moving away from Promises in favor of Observables?
2. Where can I read about the direction that Javascript is taking, so that I can have an educated discussion on the future of Javascript?
4 comments
[ 3.4 ms ] story [ 19.0 ms ] threadObservables are in position to be adopted by ECMAScript in a future spec eventually, but they are still only at Stage 1 of the ES proposal process, and also Observables don't exactly replace Promises so much as extend them.
An Observable can be thought of as a "stream" of promised values rather than just a single promised value. It's a somewhat different paradigm. From the Observable perspective a Promise is a simple Observable that produces a single value and completes immediately after. So you can see Promises are useful in an Observable world as something of a building block.
A good resource on Observables can be: http://reactivex.io/
It's focused on the main cross-platform library for Observables (ReactiveX which has implementations in .NET, Java, JS, more), but a lot of it is applicable to Observables in general and it has a lot of good "marble" diagrams that can help show why Observables can be powerful.
The dry Stage 1 ES spec itself is here: https://github.com/tc39/proposal-observable
Another factor dragging down the impression of Promises: Google search seems to love returning 5+ year old articles. They almost universally suck. Even the stuff I wrote back then was awful.
New articles are not necessarily spared, they often suffer from a number of issues: Overly Simplistic examples, fragile function boundaries, leaky variables, arbitrary 'design.'
I just updated my write-up on avoiding Promise anti-patterns: https://github.com/justsml/escape-from-callback-mountain/wik...
The main project's README shows how to rock modern Promises: https://github.com/justsml/escape-from-callback-mountain/