4 ms·
I am teaching asynchronous programming in typescript to junior developpers. And i find really tricky to tell them that async and await do MAJOR magic behind the
by lolive 1y ago
I am teaching asynchronous programming in typescript to junior developpers.
And i find really tricky to tell them that async and await do MAJOR magic behind their back to make their code readable as synchronous code.
And then, I need to detail very precisely what "Promise.all()" (and "return") really mean in the context of async/await. Which is something that (I feel) could have been abstracted away during the async/await syntax definition, and make the full magic much more natural.
- uncletaco 1y agoMan are you going to be disappointed when you read the article.
- lolive 1y agoMan, for the first time in HN, I am teased to actually read the article. Update: oh my god, I read the article. And feel completely cheated!!!! Note for my future self: continue to read only the HN comments
- lolive 1y agoTo elaborate a bit, telling them that you should not "aList.foreach(asyncMethod)", but you'd better do "Promise.all(aList.map(asyncMethod))" is NOT very easy for them.
- swid 1y agoAsync/await themselves are not that much magic really, it's a bit of syntactic sugar over promise chains. Of course, understanding promises is its own bag. ChatGPT explanation: https://chatgpt.com/share/68c30421-be3c-8011-8431-8f3385a654ba https://chatgpt.com/share/68c30421-be3c-8011-8431-8f3385a654...
- lolive 1y agoThat reminds me of my Unix guru of the 90s: "man pages ARE easy to read". [spoil: "when you are already an expert of the tool detailled in it"]
- lolive 1y agoDuring my interviews, may be I should ask them to read and understand this: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Execution_model#job_queue_and_event_loop https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... prior to any dev they plan to do in JS/TS. PS: 10 bucks that none of them would stay.