News for hackers. Stuff that matters.
Re:Async Rust never left the MVP state by K0nserv on Tuesday May 05, 2026 @05:52AM (#48020207)
There is work happening on keyword generics[0], which would let a function be generic over keywords like `async` and `const`.

For now the best option to write code that wants to live in both worlds is sans-io. Thomas Eizinger at Fireguard has written a good article about this[1] pattern. Not only does it nicely solve the sync/async issue, but it also makes testing easier and opens the door to techniques like DST[2]

I have my own writing on the topic[3], which highlights that the problem is wider than just async vs sync due to different executors.

0: https://github.com/rust-lang/effects-initiative

1: https://www.firezone.dev/blog/sans-io

2: https://notes.eatonphil.com/2024-08-20-deterministic-simulat...

3: https://hugotunius.se/2024/03/08/on-async-rust.html

Re:Async Rust never left the MVP state by ignoreusernames on Tuesday May 05, 2026 @07:15AM (#48020874)
I may have missed something, but how does “sans-io” deal with CPU heavy code? For example, if there’s some heavy decoding/encoding required on the data? Does the event loop only drive the network side and the heavy part is done after the loop is finished?
Re:Async Rust never left the MVP state by K0nserv on Tuesday May 05, 2026 @08:06AM (#48021337)
This is a great question and there isn't a definitive answer provided in the sources I linked.

Broadly I think there are three approaches:

1. For frequent and small CPU heavy tasks, just run them on the IO threads. As long as you don't leave too long between `.await` points (~10ms) it seems to work okay.

2. Run your sans-io code on a dedicated CPU thread and do IO from an async runtime. This introduces overhead that needs to be weighed against the amount of CPU work.

3. Have the sans-io code output something like `Output::DoHeavyCompute { .. }` and later feed the result back as `Input::HeavyComputeResult { .. }`, in the middle run the work on a thread pool.

Re:Async Rust never left the MVP state by K0nserv on Wednesday May 06, 2026 @04:51AM (#48033881)
Realised all of these examples are for async, but they apply equally for sync.
Re:Async Rust never left the MVP state by selfmodruntime on Tuesday May 05, 2026 @10:34AM (#48023057)
You won't get any benefits using async with CPU heavy code. Quite the opposite really.
Re:Async Rust never left the MVP state by paavohtl on Tuesday May 05, 2026 @07:23AM (#48020954)
Considering the latest commits and issues in effects-initiative are about 2 years old, the keyword generics initiative seems effectively dead.
Re:Async Rust never left the MVP state by joaohaas on Tuesday May 05, 2026 @02:25PM (#48026513)
Rust uses Zulip for lang-related discussions. The 't-lang/effects' channel is still somewhat active.
Re:Async Rust never left the MVP state by treyd on Tuesday May 05, 2026 @08:50AM (#48021813)
Keyword generics are probably not happening because it's kinda a hack.

Algebraic effects are the way forward, but that's a long way off.

Re:Async Rust never left the MVP state by satvikpendem on Tuesday May 05, 2026 @10:24AM (#48022944)
Yes I hope in the future we can get to what OCaml 5 has with their algebraic effects system, and hopefully fix any flaws we see in there, so that async will just be syntactic sugar over the underlying effects system.
Re:Async Rust never left the MVP state by conaclos on Wednesday May 06, 2026 @02:12PM (#48039550)
> For now the best option to write code that wants to live in both worlds is sans-io

Thanks for sharing! Reading the articles, it looks at me, it is a kind of manual reimplementation of the state machine generated by async? This also makes the code harder to reason with. I am unsure if it is worth the complexity.