Zig's new plan for asynchronous programs

55 points by val


mk12

It looks good for “do N things possibly in parallel then join” but that’s the simplest case. I want to see if and how std.Io would express more complicated patterns like you need in servers. I filed an issue about it here: https://github.com/ziglang/zig/issues/26056

Miaourt

Loris Cro (VP of Zig Community) discussing the article

jado

After rereading Loris' article on asynchrony and listening to his reaction of this article, I feel like I have a better understanding of the distinction Zig's API is trying to make, but I'm unconvinced on the nomenclature.

Something feels off when I'm surprised by the definition of io.async having a catch that runs the function inline. For me, and I would bet many other programmers, "async" has be conflated with "concurrent" for too long to make any semantic distinction viable. This API becomes much more intuitive to me when renamed:

Where here we've ditched the separate definition of "async" and it now just means "concurrent". I think this renaming is justified solely on how many times Loris' reaction contains "asynchrony is not enough, it also needs to be concurrent". LWN funnily enough commits to the conflation that I'm used to while trying to explain io.async:

When using an Io.Threaded instance, the async() function isn't actually required to do anything asynchronously [although the actual implementation may dispatch the function to a separate thread, depending on how it was configured] — it can just run the provided function right away.

In Zig's nomenclature, this is incorrect and should be: 'async() isn't required to do anything concurrently'. It possibly being concurrent is enough to fulfill Zig's definition of "asynchronously". This feels like a major footgun for teaching Zig, requiring you to detach these words solely for this language. Which could be fine, but I must ask, what is the value in doing so? The precision feels unnecessary.