|
|
Log in / Subscribe / Register

One and a half colors

One and a half colors

Posted Dec 3, 2025 13:56 UTC (Wed) by smurf (subscriber, #17840)
In reply to: One and a half colors by khim
Parent article: Zig's new plan for asynchronous programs

> People are talking about “two colors” because in practice that's something that actually works

Two colors because one has "async" and one has not, or one requires a somewhat-special "Io" and one does not.

Variants (shades of a color, if you'd like) are of course a related problem. Rust isn't the only language that has more than one mostly-incompatible async variant. Python has two (asyncio and trio (*)), and a third (anyio) which provides an API that runs on top of both of them. Also you can run trio on top of asyncio (in guest mode) and vice versa (trio-asyncio). All in all that makes the situation annoying but somewhat manageable.

(*) OK so there's also curio and Twisted and whatnot. Details.


to post comments

One and a half colors

Posted Dec 3, 2025 15:09 UTC (Wed) by khim (subscriber, #9252) [Link]

> Two colors because one has "async" and one has not, or one requires a somewhat-special "Io" and one does not.

You can easily predict that “sync” is just a special executor that does everything in place. That's trivial transformation and easily done if you may support more than one executor.

> All in all that makes the situation annoying but somewhat manageable.

Yes, but it's kludges on top of kludges. If you can, somehow, adopt the model that may have more than one executor then all the difference fall by wayside automatically because “sync” becomes just an async with trivial executor. But if you don't do that the every time you add new executor you make the mess worse: two executors (certain flavor of async and “sync”) are the typical norm today, three are a mess, try to converge dozen of executors in one app and the whole thing would collapse under its weight.

To untangle that mess we need to, somehow, parametrise our async functions… and Zig does precise that.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds