Created by Joshua Nelson with reveal.js
In many ways, a reaction to other languages
no ideas newer than 10 years old
Send
and Sync
unique_ptr
has overhead)
→ source-level backwards compatibilitySee my previous talk for details
In C especially, most libraries not designed with threads in mind
Example: errno
is very broken in the presence of threads (__errno_location
)
It turns out all my slides are actually just Amos blog posts repackaged
The standard library is where modules go to die
Option
and Result
unsafe
and borrow-checkingRust users want static verification
Option is a library features, not a language feature
Combinators!
let other: Vec<String> = response
.get("warnings")
.and_then(|j| j.get("other"))
.and_then(|j| j.as_array())
.map(|x| x.iter().flat_map(|j| j.as_str()).map(Into::into).collect())
.unwrap_or_else(Vec::new);
^ real code taken from cargo
Rust was created by a secret cabal of Haskell developers to teach programmers monads
Result
means errors can't be ignored
Let's pick on Go
(taken from official error handling page):
playground
f, err := os.Open("filename.ext")
if err != nil {
log.Fatal(err)
}
// do something with the open *File f
Not unique to Go - C, C++, most HTTP libraries have the same issue
Vaguely adapted from Abstracting Away Correctness
unsafe
gives you an escape hatchCompile speed vs. runtime
cfg
and unit testsLots of people!