A Design Space Exploration of Async/Await
A research blog from Brown University published the paper "A Design Space Exploration of Async/Await", which compares how async/await works across programming languages. Many languages now offer async/await so that concurrent code looks more like straight-line code, as in Python, Rust and Swift. The authors found that the languages differ much more than they expected.
The paper's example is a small program in which one function writes to a log and another starts that write in the background without waiting for it. Seven async runtimes gave four different outputs for it, and across three variations of the program, no two of the seven produced the same output. The authors describe nine design dimensions. One of them, Eagerness, decides whether an async call starts running at once ("hot")[1] or only when it is awaited ("cold").
Swift and Python with Trio both use Dynamic Extent[2], but Swift cancels the background task when the function ends, while Trio waits for it to finish. This is why Swift prints "AC" and Trio prints "ABC". To describe the design space precisely, the authors built a formal semantics on a core calculus[3] and used it to trace the program's execution.
Read the original cel.cs.brown.eduDiscussion
Sources
-
cel.cs.brown.edu
A Design Space Exploration of Async/Await


