July 20–24, 2015
Portland, OR

Programming in Rust

Jim Blandy (Mozilla Corporation)
9:00am–12:30pm Tuesday, 07/21/2015
Foundations D137/138
Average rating: ***..
(3.45, 11 ratings)

Prerequisite Knowledge

Attendees should be experienced programmers with some exposure to systems-level programming. C and C++ programmers will be well-prepared. Haskell or Go experience would also provide a good starting point.

Materials or downloads needed in advance

Attendees will need a laptop running Linux, OSX, or Windows, with the Rust compiler and the Cargo package manager installed. These are available at: http://www.rust-lang.org/


The Rust programming language offers the same degree of control over memory and performance as C and C++, while also ensuring memory safety. Rust programs are free of dangling pointers, leaks, null pointer references, and buffer overruns. Better yet, Rust enforces almost all of these properties at compile time (with the exception of buffer overruns.)

These safety guarantees make Rust well-suited for security-sensitive applications, but they also make multithreaded programming much less delicate: Rust ensures (again, at compile time) that threads can never share mutable state, even as they pass data structures among themselves by reference. Non-deterministic behavior can occur only at designated synchronization operations, not at every reference to memory.

The price? You have to think a bit more before you write.

This tutorial explains Rust’s novel characteristics, and shows how to put them to work for you. We’ll cover:

  • The principles behind Rust’s novel memory safety system: ownership, borrowing, moves, and lifetimes
  • Traits and generic types, and especially, how to use traits as constraints on generic types (one of Rust’s characteristic features)
  • Bits and pieces of the standard library that are ubiquitous in idiomatic Rust code, or too useful not to mention
  • Rust’s concurrency features, and why you needn’t hesitate to use them
  • How the Cargo package manager (reminiscent of NPM, the Node Package Manager) helps you build your code, manage dependencies on other crates, and publish your crates on the cargo.io site
  • How to use Rust’s hygienic macro system to make legible idioms from repetitive patterns in your code
  • How to use Rust’s escape hatch, the ‘unsafe’ block, to extend Rust with patterns that you know to be safe, but that Rust can’t recognize as such on its own.
Photo of Jim Blandy

Jim Blandy

Mozilla Corporation

Jim Blandy is a Free software hacker. He has worked on Guile, GDB, Subversion, and Firefox for the Free Software Foundation, Red Hat, and the Mozilla corporation.