Philly ETE Talk Summary: Rust in Production

Going into Philly ETE I had heard of Rust (programming language) but didn’t know anything about it.

Steve Klabnik positions Rust in an interesting fashion: it is both a newer C/C++, with very compelling memory management features, and as an elegant functional programming language.

On the memory management side, Rust offers compile time checks to stop segfaults, bad pointer arithmetic and threading issues from happening. If these features had existed decades ago, modern software security consultants would be robbed of many billable hours.

The compiler is strict by design, with the intent that it operates as a teaching tool to help you prevent writing code in the wrong way. The memory management model is more old-school (no garbage collection), which apparently makes it easier to slip into other runtimes, and a few Ruby gems have migrated from C/C++ to Rust.

I’m less clear on what it offers on the functional programming side, but he did offer a compelling use case: someone is writing a Postgres ORM called Diesel1 which is supposed to use the Postgres C APIs, with the goal of running much faster than writing SQL.

To blatantly steal an example from it’s documentation, this looks an awful lot like Linq / Scala / Javascript (lodash):

let results = posts.filter(published.eq(true))
  .limit(5)
  .load::(&connection)
  .expect("Error loading posts");

Steve Klabnik and some other contributors come from the web world (Rails) and the ecosystem clearly benefits from this. They build a packaging system called Cargo2, which seems to be a better NPM. For instance, packages are immutable, so you can’t withdraw them in protest (a problem that seems to have been fixed long ago by Maven).

Interestingly, the compiler team uses this as a testing tool: for every Rust release, they rebuild all the libraries on Cargo, and for minor builds they rebuild the top ~70, which gives them great insight into whether they are going to break the ecosystem with a new release (this automated tooling accounts for a significant portion of the “downloads” count on Cargo).

Rust appears to be largely sponsored by Mozilla, and they are starting to slip bits of it into the browser, with much more intended over time. They do mention some people have complained about build times – primarily Go developers, so I imagine if you’re a Scala developer looking to try this out you’ll be thrilled.

In his view, Rust is just past the edge of “the chasm”. That is, just beyond the gap between early adopters and early pragmatic users of a language, but not so far into the adoption cycle that pragmatic programmers can adopt it and still appear cool to their peers. Following this amusing line of thinking, he suggested that when people refer to software as ready for “production use” they are actually referring to whether it has jumped the chasm (and another key insight, most arguments about whether a piece of software is “good” end up with people at different points in the adoption cycle talking past each other).

There are some neat blogs that are working on “write an OS in Rust” tutorials, which look like they will be pretty interesting learning materials as they develop over time.3456

  1. https://github.com/sgrif/diesel []
  2. https://crates.io/ []
  3. http://os.phil-opp.com/ []
  4. http://jvns.ca/blog/2014/03/12/the-rust-os-story/ []
  5. https://github.com/ryanra/RustOS []
  6. https://news.ycombinator.com/item?id=10295187 []