3 ms·
An emergent property of #2 is that promises provide composition. In purely callback-oriented code composition tends to be a pain, whether it's chaining operatio
by masklinn 14y ago
An emergent property of #2 is that promises provide composition. In purely callback-oriented code composition tends to be a pain, whether it's chaining operation or synchronizing on multiple concurrent operations.
> Doesn't look like ES6 is going to pick a promises winner
Why would ES6 "pick a promises winner"? Promises don't need to be a language feature.
(ES6 will probably lead to people using coroutines with promises mostly being an implementation detail of that, e.g. http://taskjs.org/ http://taskjs.org/)
- munificent 14y ago> Why would ES6 "pick a promises winner"? If they don't, the surrounding ecosystem is less likely to standardize on a single promise implementation. That means you'll have fragmentation where foo uses Futures and bar uses Promises so you have to use a bunch of Future<->Promise shims to get them to play together. This is actually something I think is really nice about Dart: Futures are baked into the core library so they are The Way(tm) to pass around asynchronous computations.
- jasondenizac 14y agoPromise consumers have a very small interface to worry about, and in fact there are many interoperable implementations (Q, when, rsvp, etc). Unfortunately, jQuery is not one of those implementations, because rejections don't propagate. At any rate, JavaScript is not built around having a monolithic base library, and as others have pointed out, it would not make sense to have language level support for promises per se. However, I do agree that it would be great to have host APIs, for example, DOM, to make more widespread use of promises. In fact, WinJS for Windows 8 _does_ make use of promises in their async APIs.
- masklinn 14y ago> If they don't, the surrounding ecosystem is less likely to standardize on a single promise implementation. There's no need for a single promise implementation as long as they all implement the same API, in this case CommonJS Promises/A. And for the most part they do and are interoperable.