r/programming • u/alexeyr • Sep 09 '26
A Design Space Exploration of Async/Await
https://cel.cs.brown.edu/blog/design-space-async-await/
48
Upvotes
r/programming • u/alexeyr • Sep 09 '26
17
u/Next-Blackberry-991 Sep 09 '26
It says for Rust: "The task cannot respond to being cancelled."
I don't think this is true? If you cancel a task that future is dropped. Which means that all resources it owns are dropped too. Which means that you can just have e.g. an instance of a
MyOnDropGuardtype as part of your task that has aDropimpl that does whatever you want.5
u/afl_ext Sep 09 '26
I still think whatever javascript does makes the most sense except cancelling
1
u/Ethesen Sep 11 '26
It would be interesting to see Cats Effect in the comparison. It for example has backpressurized cancellation.
1
u/renozyx Sep 13 '26
I wonder why there are so many variations. I can see two useful variants: the most efficient one and the most ergonomic variant. But 9 variant??
0
u/Apprehensive_Bit7392 Sep 10 '26
Reference Strength is the sneaky row. asyncio and smol only hold a weak ref to spawned tasks, so a fire-and-forget task can get collected mid-flight if nothing keeps the handle alive. Python's docs warn about it now, which tells you how many people lost background work to it first.
-4
u/simon_o Sep 10 '26 edited Sep 10 '26
While the website gives a good overview of the general concepts of
async/await, it fails to point out that async-await is a design dead-end:Async-await poorly tries to address the symptoms of attempts to work around the root issue – "classic" threads being expensive.
Fix "threads are expensive" and you don't have to deal with the function coloring that comes with async-await.