May 18th, 2015



[For the programmers]

I just spent an hour doing a quick skim of the Rust programming language, which has hit its 1.0 release. I was pleasantly surprised.

I'd heard Rust billed as "a better version of C", and my reaction was basically ho-hum, I've heard *that* song and dance too many times before, and I haven't been especially impressed. But Rust is different: they're not trying to take C and make it a little bit better. Instead, they set out to create an entirely new language with the same *purpose* as C -- close to the metal, blazingly fast -- but with a vastly more sophisticated syntax and compiler, that automatically prevents most of the common pitfalls of C and C++.

The big deal here is the memory model, which is weird and fascinating. Instead of the usual approaches of garbage-collection (with its unpredictable pauses) or reference-counting (which is easy to screw up), Rust has a frighteningly simple concept that you can and must have exactly one "owning" pointer to any given memory item at any given time; when that owner goes out of scope, the item gets flushed. There are many idiosyncratic effects of this: the documentation goes into lots of detail about concepts like "borrowing" and "lifetimes", and it looks like it takes a while to get the hang of it. But if that saves you from the usual C/C++ headaches of memory-management, that's still likely a gigantic win.

That aside, it's a surprisingly modern language all around. While I'm not going to trade Scala in for Rust, it *does* manage to include both decent-looking OO tools (its "trait" model looks very much like it was adapted from Scala) and at least the crucial bits of functional-programming support (closures, higher-order functions). Heck, it even has hygienic macros. And while the language is strongly opinionated about good programming practices, it *does* provide you with the loopholes you need in order to do dangerous stuff when necessary.

Overall, it's clearly well-thought-out and seems intriguing. It looks like working in it probably wouldn't make me want to shoot myself in the head, which puts it ahead of most languages (including Java 6). It's pretty obviously a better choice than C, and likely is strictly superior to C++ in every respect. So if you're doing at-the-metal coding, where every cycle counts, I recommend giving it a read...