Re:JEP proposed to target JDK 19: 425: Virtual Threads (Prev...
by jayd16 on Monday May 02, 2022 @10:06PM
(#31243604)
What 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.
Re:JEP proposed to target JDK 19: 425: Virtual Threads (Prev...
by gorjusborg on Wednesday May 04, 2022 @02:55PM
(#31264417)
What 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).
Re:JEP proposed to target JDK 19: 425: Virtual Threads (Prev...
by gpderetta on Tuesday May 03, 2022 @08:54AM
(#31247674)
If 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.
you can do that as a design choice in languages that aren't exclusively single threaded.