2 ms·
Ah, async I/O with event loops is a different thing. I thought you were talking about the event loop based model of concurrent programming. I haven't used mio/
by Manishearth 11y ago
Ah, async I/O with event loops is a different thing. I thought you were talking about the event loop based model of concurrent programming.
I haven't used mio/mioco (the current async I/O solution for Rust: https://github.com/carllerche/mio/ https://github.com/carllerche/mio/, https://github.com/dpc/mioco https://github.com/dpc/mioco), but I've heard good things about it. They seem to interact with safety pretty cleanly.
Rust in 2014 was a very different language. It looked the same at the surface, but a lot of the innards (including the fact that it shipped its own async I/O solution!) have changed since then.
> might have changed
It has. Though the explicitness of Rc<RefCell<T>> is still there, since Rust prefers ownership and mutability implications to be explicit. Not much extra typing, and you can always typedef it.
> a need asynchronous communication inside a thread
Agreed. There are some coroutine libraries in Rust which are pretty nice. There is active effort towards having coroutines inside the language itself (see https://github.com/erickt/stateful https://github.com/erickt/stateful for a POC plugin, which should get RfCd at some point when it's complete).
See also: https://dwrensha.github.io/capnproto-rust/2015/05/25/asynchronous-io-with-promises.html https://dwrensha.github.io/capnproto-rust/2015/05/25/asynchr... (uses mio)
> How does the eventloop design in Servo look like? Wasn't that some integration with Spidermonkey?
Like I mentioned, I meant the event loop model of communication. We have a lot of message passing between threads, many of which are event loops.
The script thread does feed events into its own event loop (after all, JS is event looped, we need to mirror that), and it works pretty well. We do some gymnastics for thread safety (especially because the Javascript GC is involved) but the interface is safe and clean.
> but this applies also for a lot of other statically typed languages which bring in a better ecosystem for that task.
Sure, but these languages don't have quick prototyping either. Except perhaps Go.
Rust doesn't really end up with an additional burden on prototyping over any other similar statically typed language; the borrow checker is something you rarely tussle with once you get used to it.