Привет RustRush 👋
$ whoami
@spacekookie
Software Engineer at Ferrous Systems
kookie@spacekookie.de
@spacekookie
on twitter
I make some attrocious puns
An async story
An async story
How do you define success?
Rust is a young language
Rust communities are young
Yet, we have seen some amazing work from them
Lots of companies are adopting Rust
Finding Rust jobs is easier as ever
Every 6 weeks a new Rust.
Contribution pipeline is short
[Rust] is fundamentally about empowerment: no matter what kind of code you are writing now, Rust empowers you to reach farther, to program with confidence in a wider variety of domains than you did before.
– Rust book, foreword
What is unique is how the language and tooling support the community in ways that other language ecosystems do not!
A community of developers empowered by their tools and each other
In my opinion: momentum is success
Bringing new people to new domains
People who are curious and adventerous.
Supported by their tools and the community,
who are encouraged to build exciting things!
This isn’t easy!
This isn’t perfect!
Who here doesn’t know what Rust 2018 is?
This is done via the edition flag
[package]
name = "foobar"
version = "1.0.0"
edition = "2018"
2015
is default to preserve backwards compatibility
The goal of these groups is to focus on the end-to-end user experience of using Rust in each domain.
– Announcing the 2018 Domain Working Groups
This meant a low barrier-to-entry for newcomers
[…] focusing on the end-to-end experience for both sync and async networking code
Using available resources the most efficiently…
Doing things while waiting for long-running operations to finish…
Future
= calculation that hasn’t happened yet
Event Loop = runtime for Future
s
Future
until it is readyIncluded a runtime in stdlib
Rust wanted to go in a different direction
libgreen
is dead, long live libgreen
“Metal I/O” 🤘
tokio-core
mio.rs
and futures.rs
async
& await
Write code that looks synchronous/ blocking.
It actually does async under the hood!
enum Poll<T> {
Ready(T),
Pending
}
trait Future {
type Output;
fn poll(self: Pin<&mut Self>, lw: &LocalWaker)
-> Poll<Self::Output>;
}
Now provided by libcore
/ libstd
async
- marks a function as … asyncawait
- waits for something async to happenromio
A minimal tokio
fork that uses async
/await
async fn say_hello(mut s: TcpStream) { /* ... */ }
async fn listen() -> Result<(), ::std::io::Error> {
let socket_addr = "127.0.0.1:80".parse()?;
let mut listener = TcpListener::bind(&socket_addr)?;
let mut incoming = listener.incoming();
// accept connections and process them serially
while let Some(stream) = await!(incoming.next()) {
await!(say_hello(stream?));
}
Ok(())
}
(on nightly)
Future
trait now in libcore
/ libstd
futures-rs
updated to the new APIsWriting networking code has many problem domains
Future
traitKate, what hell was your point?
async
in Rust 2018 is still WIP.
But it’s on a good track,
because it’s the community that’s driving development!
Who makes Rust?
All of you! All of us!
And the language is better off because of it.
If you can remember one thing from this talk?
Collaboration takes time.
But the result will be amazing!
thank you