Comment

Comment by amluto

There’s a material distinction. In Zig (by my reading of the article — I haven’t tried it), as you say:

> await #1 runs through both 1 and 2 interleavedly, and if 2 finishes before 1, it puts a pin on it, and then returns a_result when 1 is completed.

In Rust or Python, awaiting a future runs that future and possibly other tasks, but it does not run other non-task futures. The second async operation would be a non-task future and would not make progress as a result of awaiting the first future.

It looks like Zig’s io.async sometimes creates what those other languages call a task.

parent amluto 11 months ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton