News for hackers. Stuff that matters.
Re:What's so great about JavaScript Promises? by fernandezpablo on Tuesday January 29, 2013 @01:23PM (#5135397)
can you elaborate on what is "real coroutine support" and how are these better than promises?
Re:What's so great about JavaScript Promises? by embwbam on Tuesday January 29, 2013 @01:39PM (#5135480)
Imagine if the language handled async code for you. So you could call an async function and it "returned" a value. But it still uses the event loop.

See http://taskjs.org/ for how it could work in ES6.

Re:What's so great about JavaScript Promises? by ufo on Tuesday January 29, 2013 @02:01PM (#5135598)
An analogy I like for the "language support" part is Python generators. All you need to do to turn a regular function into an async one is put the `yield` keyword where appropriate. Promises, are less worse then continuation passing style but they still require you to rewrite all your code using the promise library instead of reusing existing language constructs.

If you want to carry the analogy even further generators can also implement coroutine patterns, if you use yield as an expression (for communication) and yield from to do nested generators.