Fri, Jan 23, 2015

Fernando Borretti
Fernando Borretti

I recently gave a talk about Rust at TryoLabs, the slides of which are available here. The presentation is meant as a broad introduction, and doesn't cover methods, modules or concurrency.

Rust is an incredible example of dogfooding: built by Mozilla so they could use it to build the Servo rendering engine, which will eventually become a part of Firefox. Rust's main appeal is that it's a safer C++: It brings elements from higher-level languages like a robust type system and metaprogramming (macros!) to the world of low-level programming. The type system is designed to constrain what you can do with pointers to prevent memory errors.

As a result, working with pointers in Rust involves quite a bit of cognitive overhead. But that overhead is still present when you write C or C++ code, only it's in the form of implicit guidelines rather than explicit compiler restrictions. That is, people who write correct C will not be too troubled, because Rust merely enforces what they already do.

For the average programmer, who forgets to free memory or frees it more than once, the Rust ownership and lifetime system can take a while to get used to. The error messages, too, can be a little cryptic (but at least they are terse, compared to those of C++), but you eventually get used to the constraints of the language and the type system.

The standard library has made significant improvements as the language entered its 1.0 alpha version. What a few months ago read like a bare API reference now has better, higher-level documentation. Standarizing the way modules are documented from the start as also a good decision on the part of the Rust developers.

Having thread-local heaps and tasks that communicate with each other through asynchronous message passing, Rust takes a very reasonable approach to message passing, the Actor model, which they hope to exploit in their layout engine.

The language has already become fairly popular among the Hacker News crowd, both because of the technical credibility of Mozilla and the genuine good ideas that it brings to the table, and people have already built a good number of interesting and useful things with it: A replacement of the coreutils, a web framework, and a window manager. It will be interesting to track this project into the future.

Wondering how AI can help you?