logoalt Hacker News

jayd16last Friday at 10:11 PM1 replyview on HN

But why is this a novel concept? The idea of starvation is well known and you don't need parallelism for it to effect you already. What does zig actually do to solve this?

Many other languages could already use async/await in a single threaded context with an extremely dumb scheduler that never switches but no one wants that.

I'm trying to understand but I need it spelled out why this is interesting.


Replies

shikon7last Friday at 10:57 PM

The novel concept is to make it explicit where a non-concurrent scheduler is enough (async), and where it is not (async-concurrent). As a benefit, you can call async functions directly from a synchronous context, which is not possible for the usual async/await, therefore avoiding the need to have both sync and async versions of every function.

And with green threads, you can have a call chain from async to sync to async, and still allow the inner async function to yield through to the outer async function. This keeps the benefit of async system calls, even if the wrapping library only uses synchronous functions.