Hey, there's a local Rust meetup

in the Triangle area!

Check them out!

meetup.com/triangle-rustaceans/

rust:

Systems Programming For The

Rest Of US

Get these slides at slides.com/bstrie/ato-2017

but first, A Quick Teaser...

# Python ranges
for i in range(0, n):
    # Do something n times
// Rust ranges
for i in 0..n {
    // Do something n times
}
// Javascript closures
let x = 2;
let y = (z) => z + x;
y(3);  // 5
// Rust closures
let x = 2;
let y = |z| x + z;
y(3);
# Ruby iterators
(0...x).inject(0) {|sum, i| sum + i}
// Rust iterators
(0..x).fold(0, |sum, i| sum + i)
; Assembly for above example
lea	eax, [rdi - 1]
lea	ecx, [rdi - 2]
imul	rcx, rax
shr	rcx
lea	eax, [rcx + rdi - 1]
((n - 1) * (n - 2) >> 1) + n - 1
((n1)(n2)>>1)+n1((n - 1) * (n - 2) >> 1) + n - 1
// Rust iterators
(0..n).fold(0, |sum, i| sum + i)

What Is Rust?

  • Systems language originally from Mozilla
  • Developed in the open by a large community of contributors and several full-time employees

What Is Systems Programming?

  • Nothing stands between you and the hardware at runtime
  • No code runs that you didn't ask for
  • Provides the foundational layers that other layers build upon

Why make a new language?

  • Browsers compete on performance, and today that demands concurrency
  • Browsers are a critical attack vector, and today that demands memory safety

What is memory safety?

  • Memory management errors are a distinct class of programming bugs
  • 50% of all critical security bugs in Firefox are because of subtle memory errors
  • Nearly all languages today use garbage collection to prevent memory errors

What about C?

  • C has many good qualities, but protection against memory errors is not among them
  • Invented in an era when networking was rare, security was not prioritized, and the impact of memory errors on security was not well-researched

What about Other langs?

  • All popular systems languages build on C and inherit C's challenges
  • Even less popular languages don't provide satisfactory solutions to our problems

What about modern C++?

  • Plugging up memory safety holes clashes with backwards compatibility
  • Modern revisions focus mostly on usability, sometimes even to the detriment of memory safety
decltype(auto) foo() {
    int x = 1;
    return x;
}
decltype(auto) bar() {
    int x = 1;
    return (x);
}

What Is one to do, then?

  • Merely extending an existing language to add memory safety would break compatibility anyway
  • If you're going to be compatible with nothing, might as well start from scratch with the things modern devs expect

Where is Rust being used?

  • Mozilla, for application development
  • Dropbox, for backend development
  • Chucklefish, for game development
  • Tilde, for runtime extension
  • Tock, for embedded development

Who'd benefit from rust?

  • Veteran systems programmers looking for memory safety guarantees
  • High-level programmers looking to learn best practices for systems programming
  • Full-stack teams with shared responsibilities

How to write it?

  • Text editor support for vim, emacs, etc.
  • IDE support via plugins, especially VSCode, and official plugin support from Intellij
  • forge.rust-lang.org/ides.html

How to debug it?

  • Tools that work with C++ tend to work with Rust, e.g. LLDB
  • Official support from GDB

How to Get it?

  • Increasingly available in distro package managers
  • Official installer with toolchain at            rust-lang.org/install.html

How to learn it?

  • Official free e-book, "The Rust Programming Language"                     doc.rust-lang.org/stable/book/second-edition/
  • Online standard library reference        doc.rust-lang.org/std/index.html
  • Dive right in rustbyexample.com
  • Introductory screencasts intorust.com
  • "Programming Rust" by O'Reilly

How to re-use it?

  • Take advantage of our central package resource, crates.io
  • Integrates with our official package manager, Cargo, which comes bundled with the Rust installation

How to talk about it?

  • Official forums on users.rust-lang.org
  • Official IRC channels at irc.mozilla.org
  • Official development repositories at github.com/rust-lang/rust
  • Subreddit at reddit.com/r/rust

What features does it have?

Well, let's see how much time we have left...

Thanks for coming!

go forth and rust!

Get these slides at slides.com/bstrie/ato-2017

Rust: Systems programming for the rust of us

By bstrie

Rust: Systems programming for the rust of us

  • 1,404