The future of futures
whoami(1)
Katharina Fey ( @spacekookie
)
I also make some attrocious puns
whoami(2)
I do Rust things!
berlin.rs
use[ful|less]
librariesRace conditions
vs
Inefficient scaling
Rust is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety.
Memory safety
and
Thread safety
This would not compile!
error[E0382]: capture of moved value: `f` --> main.rs:13:14
|
10 | thread::spawn(move || {
| ------- value moved (into closure) here
...
13 | drop(f);
| ^ value captured here after move
|
This will also not compile!
Rust breaks down these spectrums
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 that?
What does it know?
Does it know anything?
Let’s find out!
“Do this thing but don’t make me wait”
Not just a new Thread
No, not that type of Futures
Future
= calculation that hasn’t happened yet
Event Loop = runtime for Future
s
Future
until it is readyI’m here to show code and talk history
and I’m all mostly out of code
libgreen
Included a runtime in stdlib
Rust wanted to go in a different direction
libgreen
is dead, long live libgreen
Sorry, did I say libgreen, I meant mio.rs
mio.rs
“Metal IO” 🤘
= no discernible* runtime overhead
= code that you can’t write better by hand
Abstraction layers disappear at compile-time
tokio-core
mio.rs
and futures.rs
It’s state machines all the way down
Reminder: Futures are zero-cost-abstractions.
They disappear from the code at compile-time!
async
& await
Write code that looks synchronous but really isn’t
Clever people are working on it
In Groups
You might even call them “working groups”
kinda 😅
async
/await
syntax in nightly compilerExpect more concrete progress early-2019
Follow me on twitter @spacekookie
Or: kookie@spacekookie.de