Tokio: Runtime for writing reliable asynchronous applications with Rust
github.com
github.com
That said, I'm always happy to answer questions.
I understand the sentiment re v1. In reality, Tokio v0.1 was pretty much 1.0. We never cut 1.0 because async/await was in the works and it was unclear when it would be released. Now that async/await is out, 0.2 was a big change. We need some time to stabilize our APIs and collect user feedback. This process is happening now and going well.
I wouldn't call it bad pr.
There are plenty of crates that are stable and production-ready, but with 0.x versions.
In some cases ironically authors don't want to bump the version to 1.0, because the crates are so widely used and stable, that the mere version bump would be an unnecessarily big change (e.g. the most used libc crate will likely stay as v0.2 forever).
edit: my question may not be formatted correctly, but basically I am asking whether there is cooperation between the 2 projects, or they are competing each other
The Tokio team has been very active on that front. Recently, we've shipped a new strategy to improve the cooperative scheduler (https://tokio.rs/blog/2020-04-preemption/), and a bunch of other new utilities (https://github.com/tokio-rs/tokio/releases/tag/tokio-0.2.12, https://github.com/tokio-rs/tokio/releases/tag/tokio-0.2.11).
Standardization can be extracted once proven. This is how `std::future` came to be.
async-std aims to do that last sentence as cleanly as possible, without having to support a legacy interface. I found it builds faster because of that and that's why I chose it.
smol (the new kid in the block) aims to async-ify network types by simply wrapping them in Async<T>. It also aims to be as few lines of code as possible.
They are all different approaches to the same problem. The ability to experiment with different approaches is precisely why Rust doesn't have a prescribed async runtime (or prescribed error types, or many other things).
If merely solving the problem is all you care about, pick tokio. It should be able to use async-std crates, but async-std can't use it. smol can use anything but is a bit unproven.
A month ago I wrote a blog post about the evolution of async Rust and its async runtimes. Hopefully this answers your questions!
https://stjepang.github.io/2020/04/03/why-im-building-a-new-...
I also found this blurb from the website to be confusing:
> Zero-cost abstractions Tokio's run-time model adds no overhead compared to an equivalent system written entirely by hand.
This sounds like Tokio's impl is comparable to other impl's of "the same" system, but how does it compare to "naked Rust"?
One of the surprising things with rust here, is that it define only the syntax and some bare traits AND ALLOW TO PLUG ANY RUNTIME.
This mean you can "swap" runtime implementations and even build your own.
One recent example is:
https://www.reddit.com/r/rust/comments/g917ad/smol_stjepang_...
This is in contrast with Go/Erlang/.NET, etc where the runtime for it is made for you, but can't be changed. This is cool where things are mostly fine all the time, but rust being a SYSTEM lang allow this is neat (example: Embebed scenarios where a regular runtime is too heavy).
Note: This template show in other places, where for example you can swap the allocator or the (default) hash function.
If `Future::poll` returns Pending, once it becomes ready to do more work, it notifies the executor, the executor then schedules the future to be polled again.
The compiler desugar the async/await to state machines and that is melted away by regular means. Also, the quality of the runtime elected must take some credit.
Actually C++20 comes with only the minimal support for coroutines in the std library. If you want to do anything useful, you need to implement a promise type yourself which is very hard to do without using one library that does that.
And that I won't need to rewrite it when I try out the same code with another C++20 compiler.
Ultimately I've just been more productive in Go for the time being, but I remember definitely see the potential down the road for great things.
Has async/await permeated the ecosystem? Is the book more fleshed out?
For docs, there are some now and I expect it to improve a lot throughout the year.
We also just posted mini-redis as a larger "real world" example: https://github.com/tokio-rs/mini-redis
https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...
The point is that "colour" is introduced to make a meaningful distinction in order to achieve a desirable property. He's enamored by Go which erases this distinction, but it does so by giving up nearly all of the benefits of the event-driven model: very small captured state for resuming the continuation.
The argument is the reverse: it's too hard to explicitly manage side effects, so we should make our functions implicitly, pervasively side-effecting. E.g. allowing any function to throw an exception without declaring this in their signature is widely agreed to be a better approach than Java-style checked exceptions; the argument goes that we should also allow any function to be async without declaring this in its signature.
(I think there's some merit to the argument in languages that aren't powerful enough to express functions that are polymorphic over async-ness. Personally I use languages with higher-kinded types and then you get the best of both worlds: you have an explicit distinction between async and not, but you can write functions that work with both)
In Rust you can easily call an "async colored" function from a "sync colored" one by running it to completion with the executor of your choice. With that you can prevent async bleeding all over your codebase.
I'm a programmer, not a marketer :) Happy to take suggestions on the copy.