4 ms·
async/await doesn't solve anything with concurrency, working on a single thread does. you can do that as a design choice in languages that aren't exclusively s
by gorjusborg 4y ago
async/await doesn't solve anything with concurrency, working on a single thread does.
you can do that as a design choice in languages that aren't exclusively single threaded.
- jayd16 4y agoWhat do you mean by this? Async/await provides a standard way to handle message passing between threads, a cleaner syntax than nested callbacks and a lot of other niceties over raw threading. Async/await is in many single and multi-threaded languages so I'm not clear on what you're saying.
- gpderetta 4y agoIf you are using threads you wouldn't use nested callbacks in the first place. In a proper threaded model you can use exactly the same syntax that you would use with async/await (futures, future combinators, message passing what have you) except you do not have to randomly annotate your code with awaits.
- gorjusborg 4y agoWhat I mean is: async/await is just syntactic sugar over promises/futures and those just buy you a way to schedule future computation. The js runtimes schedule all your code on a single thread. It's the fact your code only runs on a single thread that 'solves concurrency' because data races can't happen if one thread of code is allowed to access memory at a time. You can set up the same limitation in a threaded program/language, and people have (see vert.x, clojure STM, and others).