News for hackers. Stuff that matters.
Re:Introduction to WebRender by slezyr on Friday September 22, 2017 @01:31PM (#15314094)
How you do multiple async http requests in rust? Last time I checked the only way do it was using tokio crate. But tokio is a huge mess and looked like Rust++. I.e. some language based on rust.
Re:Introduction to WebRender by ekidd on Friday September 22, 2017 @01:39PM (#15314147)
There's a ton of work being done at the compiler level to make Tokio more pleasant. This includes:

1. async/await. This is analogous to async/await in C# and ES6, and should make the syntax a lot nicer. https://github.com/alexcrichton/futures-await

2. Coroutines. This is the supporting technology for async/await. https://github.com/rust-lang/rfcs/blob/master/text/2033-expe...

3. 'impl Trait'. This provides a way to say, "Look, my return type implements 'Trait', but the actual type declaration is way to tedious to write out, and anyway, it's private. This will help a lot with cleaning up complex Tokio types. https://github.com/rust-lang/rfcs/blob/master/text/1522-cons...

At work, we use Rust, but we're avoiding using Tokio until these features land.

Re:Introduction to WebRender by steveklabnik on Friday September 22, 2017 @01:38PM (#15314145)
You're being downvoted because this is quite offtopic for this thread; I suggest you post to https://users.rust-lang.org/ for these kinds of questions.
Re:Introduction to WebRender by kibwen on Friday September 22, 2017 @01:46PM (#15314197)
I suspect you're being downvoted for being off-topic, consider asking on reddit.com/r/rust or StackOverflow.
Re:Introduction to WebRender by slezyr on Friday September 22, 2017 @02:14PM (#15314432)
I want response from Firefox/Servo devs. They need async http requests and they have experience in using those.
Re:Introduction to WebRender by kibwen on Friday September 22, 2017 @02:29PM (#15314551)
I don't believe that Firefox's http code is using Rust at all, and Servo's http code is notoriously neglected due to prioritizing development on the layout engine and style engine. At the moment I expect they're in the same boat as ekidd, waiting for the async/await experiments to yield fruit.
Re:Introduction to WebRender by metajack on Friday September 22, 2017 @04:28PM (#15315508)
We use hyper and rolled our own async support I believe, since it didn't exist at the time, but it is quite neglected and the general plan has been to move to futures and tokio. Firefox's network stack is called necko, and has been async for a long time I believe.
Re:Introduction to WebRender by slezyr on Friday September 22, 2017 @02:47PM (#15314697)
> Servo's http code is notoriously neglected due to prioritizing development

Is it? It's freaking hard to make http code in rust at all. I just checked it's source and they use some old hyper's methods inside, which aren't available in recent versions. So you can use it only with tokio. Tokio is nightmare who those, who tries to learn rust. And I can't find a way around it.

> At the moment I expect they're in the same boat as ekidd, waiting for the async/await experiments to yield fruit.

I think that almost all rust users/devs there right now.

Re:Introduction to WebRender by tomjakubowski on Friday September 22, 2017 @05:40PM (#15316104)
If you just want to do an occasional one-off async http request, then tokio is probably overkill, at least until async/await end up in the language.

The simple way is: spawn a background thread, make a channel, pass the write end to the background thread, issue the http request synchronously using whatever crate you want on the background thread, write the result back over the channel, and exit the background thread. In the main thread, poll the read end of that channel from your event loop.

Rust decided not to ship with a scheduler/runtime built in like Go and Node.JS have. This makes you do a little more work for this kind of thing, in exchange for finer control than a language with a runtime can provide.

Re:Introduction to WebRender by Manishearth on Saturday September 23, 2017 @01:13AM (#15318259)
Neither Firefox nor Servo use async http requests in the Rust code.

The only Rust code in Firefox's network stack is the URL parser. The rest of the stack is in C++, and I believe it handles async.

Servo's network code is still pretty premature. I plan to poke at tokio-ifying it at some point, or at least having better thread pooling.