News for hackers. Stuff that matters.
Re:Tokio 1.0 – async runtime for Rust by megaman821 on Thursday December 24, 2020 @11:33AM (#25528927)
That is an interesting positive for async/await that I had not heard before.

Why are there so many libraries that depend on Tokio then? If only the edges need to actually use an async runtime, the middle-tier libraries can just be plain futures.

Re:Tokio 1.0 – async runtime for Rust by jeff-davis on Thursday December 24, 2020 @12:56PM (#25529712)
Because the standard library (and a lot of other libraries) are mostly blocking. You can't use blocking code effectively with async.

In other words with async you have to use code that knows how to yield, but the benefit is that you have a lot of flexibility in the runtime. That means you can scale up, scale down, and fit it into weird environments (like in other programs that aren't expecting concurrency).

Threading (or process model) has a lot of upside though, too. For one, it's pre-emptive, so scheduling can be more "fair". For another, it's a lot easier to debug (erlang does a great job here).

I'd generally default to using threads, unless I have a specific reason for async and/or the code is fairly low-level and might be used in a variety of environments.

Disclaimer: don't take my claims as authoritative. I know a few things from seeing what works and not, but I could be wrong on some of the finer points.