3 ms·
I use at least 3 separate runtimes: tokio and 2 no_std runtimes (rtic and embassy). The latter would probably not be possible at all if there was an "official"
by wyager 3y ago
I use at least 3 separate runtimes: tokio and 2 no_std runtimes (rtic and embassy). The latter would probably not be possible at all if there was an "official" runtime, because the official runtime would inevitably require allocation, and if it existed they wouldn't bother writing async in a flexible enough way that you could use it without an allocator.
The way async is implemented in rust is actually technically quite impressive, and would almost certainly not exist if there were some official green thread solution.
You could solve async/non-async polymorphism via the introduction of HKTs (and monads) - perhaps eventually they will be forced to do that.
In the mean time, if they can make a few changes like stabilizing TAITs and async traits, that would go a long way to improving the ergos of async.
- zozbot234 3y ago> You could solve async/non-async polymorphism via the introduction of HKTs Rust has stabilized GATs, which are comparable in power to HKTs while having better interop with the language's broader feature set.
- wyager 3y agoI haven't thought about it super hard, but I suspect the ergos of that would be quite poor, as you would need to pass around the type of the trait object, even though all you really care about is the associated type constructor.
- karavelov 3y agoFor interop between runtimes, they need to add `std::async` IO traits that could be implemented by each runtime.
- thinkharderdev 3y agoAnd APIs for timers!
- weinzierl 3y agoNot sure if this is an apt comparison, but I like to think that the allocator is a good precedent. Similar to the async runtime most software needs one and most developers don't care much which one they use and are happy with the default allocator. Another similarity is that both are not just some ordinary old library but required by language features. We also usually don't use multiple ones in a single application. Still we allow the developer to choose an allocator or bring their own one.