4 ms·
the fact that there is a long chapter in a book series written on the edge cases of javascript[0] leads me to believe that it's not generally well understood ei
by weaksauce 5y ago
the fact that there is a long chapter in a book series written on the edge cases of javascript[0] leads me to believe that it's not generally well understood either.
0. https://github.com/getify/You-Dont-Know-JS/blob/1st-ed/async%20%26%20performance/ch3.md https://github.com/getify/You-Dont-Know-JS/blob/1st-ed/async...
- horsawlarway 5y agoJS uses an event-loop (which is really just a variation of a message/event queue that we've been using for GUI based applications for decades now). If you understand this, asynchronous code in JS is pretty easy to understand. https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop https://developer.mozilla.org/en-US/docs/Web/JavaScript/Even... You can go from nothing to mostly full-fledged promises in about 200 lines of code: ex - https://www.promisejs.org/implementing/ https://www.promisejs.org/implementing/ async/await is pure sugar on top of promises (it's literally just wrapping the rest of the function in a .then() for you, and coercing the return value of your function to always be a promise)
- davelnewton 5y agoIMO that's an explicitly different issue than a comparison between Promises/async/await and Ruby's metaprogramming, though. Not to mention that part of the issue with Promises is the various polyfills invented before broad acceptance, which is a separate can of worms, and a different type of complexity than the (relatively) heavy use of metaprogramming in Ruby (relative to JS).