5 ms·
Oh, I see. The article is saying that async is required. I thought it was saying that parallelism is required. The way it's written makes it seem like there's a
by tines 1y ago
Oh, I see. The article is saying that async is required. I thought it was saying that parallelism is required. The way it's written makes it seem like there's a problem with the code sample, not that the code sample is correct.
- Retr0id 1y agoThe article later says (about the server/client example) > Unfortunately this code doesn’t express this requirement [of concurrency], which is why I called it a programming error I gather that this is a quirk of the way async works in zig, because it would be correct in all the async runtimes I'm familiar with (e.g. python, js, golang). My existing mental model is that "async" is just a syntactic tool to express concurrent programs. I think I'll have to learn more about how async works in zig.
- sunshowers 1y agoI think a key distinction is that in many application-level languages, each thing you await exists autonomously and keeps doing things in the background whether you await it or not. In system-level languages like Rust (and presumably Zig) the things you await are generally passive, and only make forward progress if the caller awaits them. This is an artifact of wanting to write async code in environments where "threads" and "malloc" aren't meaningful concepts. Rust does have a notion of autonomous existence: tasks.
- Retr0id 1y agoThanks, this clears things up for me. I suppose I conflated "asynchrony" (as defined in the article) and "async" as a syntax feature in languages I'm familiar with.
- m11a 1y agoI think that notion is very specific to Rust's design. Golang for example doesn't have that trait, where the user (or their runtime) must drive a future towards completion by polling.
- sunshowers 1y agoRight, but Go is an application-level language and doesn't target environments where threads aren't a meaningful concept. It's more an artifact of wanting to target embedded environments than something specific to Rust.
- jayd16 1y agoThank you so much for the added context. This explains the article very well.