News for hackers. Stuff that matters.
Re:Tokio 1.0 – async runtime for Rust by rossmohax on Wednesday December 23, 2020 @02:53PM (#25521439)
It is unfortunate, that libraries have to be coded against specific runtime and not generically. There is tokio and there is smol (likely discontinued, since author left rust), maybe other runtimes will emerge, but whole ecosystem is already tied to tokio.
Re:Tokio 1.0 – async runtime for Rust by WhatIsDukkha on Wednesday December 23, 2020 @03:30PM (#25521830)
https://github.com/stjepang?tab=overview&from=2020-12-01&to=...

"""smol (likely discontinued, since author left rust)""" doesn't seem well supported and smol is used by async-rs these days iirc.

Re:Tokio 1.0 – async runtime for Rust by ibraheemdev on Wednesday December 23, 2020 @02:58PM (#25521498)
async-std [0] is pretty widely used as well.

[0]: https://github.com/async-rs/async-std

Most libraries can be used with different runtimes. Hyper for example, which uses Tokio by default, can be configured to use an async-std executor.

Re:Tokio 1.0 – async runtime for Rust by mmastrac on Wednesday December 23, 2020 @03:02PM (#25521550)
I always get a weird vibe from async-std. I respect the people working on it, but it feels like it's trying to boil the ocean.

I'd be very interested in hearing other opinions, as my Rust project [1] is currently stuck on an older version of Tokio while I wait for deps to update. I'm either going to have to bite the bullet and replace deps or bite more bullets and find a different runtime.

[1] https://github.com/mmastrac/stylus/

Re:Tokio 1.0 – async runtime for Rust by aliceryhl on Wednesday December 23, 2020 @03:16PM (#25521673)
Warp should be out pretty soon. It was mainly waiting for hyper, which is already out for 1.0.
Re:Tokio 1.0 – async runtime for Rust by mmastrac on Wednesday December 23, 2020 @03:18PM (#25521694)
Ah thanks. I researched this a while back and it didn't seem like there was any ETA but perhaps I can just wait for a bit now.
Re:Tokio 1.0 – async runtime for Rust by octoberfranklin on Wednesday December 23, 2020 @09:33PM (#25524551)
It bugs me that that library will spin up a scheduler without being asked to do so.

As I understand it, that difference (vs Tokio) was the main driver behind the projects splitting.

I also think it's a bit presumptuous for them to name themselves "std". It'll be even more ridiculous in the likely event that Tokio becomes the std:: asynchronous I/O library. It's asking for confusion.

Re:Tokio 1.0 – async runtime for Rust by rossmohax on Wednesday December 23, 2020 @03:46PM (#25522017)
Can't find async-std feature here: https://github.com/hyperium/hyper/blob/master/Cargo.toml

do you have an example?

Either way, "can be configured" means that custom code for each runtime must be written, it is not like lets say "Futures", which can be used generically.

Re:Tokio 1.0 – async runtime for Rust by ibraheemdev on Wednesday December 23, 2020 @04:36PM (#25522512)
Here is an example: https://github.com/async-rs/async-std-hyper/blob/master/READ...

You do have to write a ~50 loc compat layer. However, most of the compat layer is due to the fact that tokio's `AsyncRead` and `AsyncWrite` are different from the standard futures crate, which may change in the future [0]. After that, you just have to implement `hyper::Executor` for async-std's `spawn`, and `hyper::Accept` for async-std's `TcpListener`.

Of course, it is not as generic as "Futures", but it is relatively simple to do. As @steveklabnik mentioned above:

> There's a few points here that still need some interop work. The intention is to fix that, but it's non-trivial. We'll get there.

[0]: https://github.com/tokio-rs/tokio/issues/2716

Re:Tokio 1.0 – async runtime for Rust by octoberfranklin on Wednesday December 23, 2020 @09:36PM (#25524567)
> tokio's `AsyncRead` and `AsyncWrite` are different from the standard futures

The standard futures library does not have an AsyncRead or AsyncWrite:

https://doc.rust-lang.org/std/future/index.html

Re:Tokio 1.0 – async runtime for Rust by ben0x539 on Wednesday December 23, 2020 @10:33PM (#25524822)
Re:Tokio 1.0 – async runtime for Rust by ibraheemdev on Thursday December 24, 2020 @12:02AM (#25525191)
Yup, that is what I was referring to.
Re:Tokio 1.0 – async runtime for Rust by ibraheemdev on Wednesday December 23, 2020 @03:15PM (#25521669)
Since when did Stjepang leave Rust?
Re:Tokio 1.0 – async runtime for Rust by jedisct1 on Wednesday December 23, 2020 @05:30PM (#25523031)
He switched to Go.

Stjepang is a very smart person and I'm actually quite excited about what he's going to bring to the Go world.

Re:Tokio 1.0 – async runtime for Rust by volta87 on Thursday December 24, 2020 @04:19AM (#25526126)
Was there a blogpost? Or when/where was this announced?
Re:Tokio 1.0 – async runtime for Rust by earwaxauditor on Wednesday December 23, 2020 @06:40PM (#25523588)
Rust/Go really are the Emacs/Vim of programming languages: little in common but commonly mentioned in the same breath.
Re:Tokio 1.0 – async runtime for Rust by rossmohax on Wednesday December 23, 2020 @03:44PM (#25521997)
he posted a goodbye issue on a smol repo, but since then deleted it, so maybe he changed his mind
Re:Tokio 1.0 – async runtime for Rust by gpm on Wednesday December 23, 2020 @03:52PM (#25522087)
I found the github issue in Google cache. I'm not sure it's really fair of me to post this link here, but equally I think it's better to give the actual text rather than leave it vague.

https://webcache.googleusercontent.com/search?q=cache:PRjMyv...

Re:Tokio 1.0 – async runtime for Rust by indepnd on Wednesday December 23, 2020 @04:35PM (#25522505)
Thanks for the pointer! It's really sad to hear this. I'm using smol in my project and really like it. I didn't know the author left until now. It's a great loss for Rust, in my opinion.
Re:Tokio 1.0 – async runtime for Rust by forrestthewoods on Wednesday December 23, 2020 @02:59PM (#25521507)
> and there is smol (likely discontinued, since author left rust)

Whoa. smol is great. Why’d the author leave?

Re:Tokio 1.0 – async runtime for Rust by octoberfranklin on Wednesday December 23, 2020 @09:31PM (#25524544)
That's not entirely true. If you want to write an entire standalone application that compiles into a binary and starts up a scheduler, then yes, you have to pick a scheduler runtime.

If you're writing a library to be used by others you can very often expose only types which come from std::futures. The result will work with all of the runtimes.

Re:Tokio 1.0 – async runtime for Rust by Xevi on Wednesday December 23, 2020 @05:59PM (#25523279)
Woah, I didn't know about that. Does this mean Rust only has one maintained runtime now? Namely Tokio.
Re:Tokio 1.0 – async runtime for Rust by FridgeSeal on Wednesday December 23, 2020 @06:38PM (#25523562)
Async-std is still actively maintained and developed.
Re:Tokio 1.0 – async runtime for Rust by Xevi on Wednesday December 23, 2020 @08:03PM (#25524131)
I was under the impression that it's based on Smol, but maybe I'm wrong.
Re:Tokio 1.0 – async runtime for Rust by nicoburns on Wednesday December 23, 2020 @08:16PM (#25524212)
It has separate maintainers (a whole team), who will continue to maintain the parts of smol they are using. Smol is relatively small and sinple.
Re:Tokio 1.0 – async runtime for Rust by sanxiyn on Wednesday December 23, 2020 @06:17PM (#25523411)
I think it's rather that smol is "complete" and doesn't need much maintenance.
Re:Tokio 1.0 – async runtime for Rust by Xevi on Wednesday December 23, 2020 @08:05PM (#25524149)
Maybe that's true. I don't know how complex these things are, or if they will be affected by future changes in the language, but it feels weird to say that a critical piece of software is complete. I wonder if many new libraries will use Smol.
Re:Tokio 1.0 – async runtime for Rust by gpm on Wednesday December 23, 2020 @10:40PM (#25524841)
One of the principles that stjepang was very keen on for smol was that libraries shouldn't depend on it. Libraries should be written in an async-executor generic way and the end binary should then be free to use smol as the executor, or tokio, or anything else.

I'm currently using smol (in an application I'm developing - not just a library) and I don't think this will scare me away. He appears to still be responding to pull requests, and smol consists of a reasonably small amount of very high quality code.

Re:Tokio 1.0 – async runtime for Rust by jayd16 on Wednesday December 23, 2020 @04:34PM (#25522491)
If core rust provides an interface for async/await why does usage of it tie you to a specific runtime? Whats the point of that?
Re:Tokio 1.0 – async runtime for Rust by steveklabnik on Wednesday December 23, 2020 @04:43PM (#25522577)
Usage of it, on its own, does not tie you to a specific runtime.

Using runtime-specific features and APIs ties you to a specific runtime.

Re:Tokio 1.0 – async runtime for Rust by jayd16 on Wednesday December 23, 2020 @04:49PM (#25522624)
Is this just an artifact of the current work in progress state of things? Is it just a matter of the interface settling and library authors providing a bit more configuration options to become runtime agnostic?
Re:Tokio 1.0 – async runtime for Rust by steveklabnik on Wednesday December 23, 2020 @04:52PM (#25522666)
I am not a super expert in all of the exact details, but my understanding is that generally, there are a few features that don't have a common trait yet. For example, "spawn me a new task." Once those traits exist, libraries can be written against them, and it'll all be agnostic. But you only even run into that kind of problem if you need that specific API in the first place.