Ask HN: Is JavaScript abandoning Promises
4 comments
Promises are one of those features misunderstood for 2 reasons.
Several leading initial library implementations were broken from day 1, and couldn't/wouldn't later introduce breaking changes to existing users.
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/
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/
Promises are not going anywhere.
I keep hearing about async/await being a cleaner way to write asynchronous code in JavaScript but async/await actually makes use of promises in the implementation. That's what I would have talked about. For more: https://hackernoon.com/6-reasons-why-javascripts-async-await...
Promises aren't going anywhere. async/await is built on top of Promises, for instance.
Observables 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
Observables 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
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?