Re:Let’s make a JavaScript Wait function
by sametmax on Sunday November 12, 2017 @03:25PM
(#15682463)
How is that possible ? Await doesn't have this effect in python 3 and v8 is faster than cpython.
[ Parent
| on HN ]
Re:Let’s make a JavaScript Wait function
by saas_co_de on Sunday November 12, 2017 @04:07PM
(#15682631)
Promises require creating and modifying objects that contain the promise state which plain callbacks do not.
The difference in micro-benchmarks can be huge: https://jsperf.com/native-promise-vs-callback
That example is a probably a worst case scenario because of how it is constructed, but on my MBP it still gets around 1M promises created and resolved per second.
For a typical web app or api you will not see any benefit in using callbacks over async/await in your application code unless you are consistently doing something that requires 1000's of promises per request.