Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Your casual ambivalence for #1 makes me think you don't appreciate the greatest value of promises: that they are values, objects.

Returning control to the caller is half the story. Along with returning control- which indeed is what is happening, no illusion, if the promise is triggering a non-blocking routine- the promise itself is returned: that object is what makes promises great.

We have no other object for an execution or process in JavaScript: a promise, the value it returns, is an object. Objects can be used and talked about inside JS. If there is no object, there's nothing to compute about. A promise is a first class execution that we can compute about.



What about timeout ids? I think I am missing the point.


timeout IDs are similar in a sense. By having the promise as an object, you can do neat things to modify program control flow as a separate concern from resolving a particular asynchronous operation. Sure, you can compose promises, just like you might with callback-oriented code. But you can also do neat things like await an object graph of mixed synchronous and promised values, eg: https://npmjs.org/package/resolved




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: