Rust Gets a Lot of Things Right

So some coworkers and I have been recently checking out the relatively new language Rust, and so far we’ve been very impressed.

Rust gets a lot of things right. You should check it out. If you use C or C++ on a regular basis, you really should check it out.

A Systems Language with Better Features

Rust is a systems language, but it has a lot of awesome features you don’t normally see in system languages, such as:

A Good Memory Model

It’s pretty obvious that the developers of Rust paid a lot of attention and care to Rust’s memory model. It shows. The result is a lot of very nice safety features statically guaranteed by the compiler:

  • You can’t cause segfault in Rust**.
  • You can’t leak memory.
  • You can’t dereference a null pointer. (null isn’t even a thing in Rust!)
  • Even though it’s easy to share mutable data between Tasks in Rust, the compiler only allows one task to mutate the data at any given time. And this is enforced at compile time!

The cool thing about Rust is that it provides all these cool features without sacrifices to speed or safety. Rust is still very young, and it’s already nearly as a fast as C!

Potential Usability for Embedded Systems!

This is one of the things I’m most excited about. My language of choice is Haskell, but for a variety of reasons C is still the defacto choice for embedded development.

However, fewer of those reasons apply to Rust. It’s currently possible to run Rust without an OS! It’s also possible to avoid the garbage collector in Rust, which is a big deal for embedded systems. And it’s possible that future versions of Rust will have the garbage collector as a library, which would be even better!

There are still some other catches (mostly due to LLVM) but Rust is definitely the most powerful language that I might actually be able to use on an embedded project.

A Potential Gateway Drug?

I’ve explained Algebraic Data Types to people before, and even compared them to enumerations, but probably half the time the response I get is: “Well that’s kinda cool, but I’m not sure what I’d use them for.” But when I show people the Rust enum, the response I get is: “woah, that looks ridiculously useful.”

I think Rust calling Algebraic Data Types ‘enum’ was a really really good idea.

The more people I can get to use Rust and get addicted to a world without null’s and awesome features like pattern matching and algebraic data types, the better.

** Well, actually it does let you do all of these things. It’d hardly be a systems language if it didn’t. But it forces you to put any potentially dangerous code in an unsafe block.

  • cj says:

    I’m also looking for a nice modern language that could be used in embedded software (mostly automotive in my case). I’m looking at Rust since it’s beginning and also think it can become the one I search in a few years.

    In my mind the most promising is Nimrod ( I compiles to C (and have therefore a good integration with C) ; it have powerful macros, a GC that seems ok for soft RT and a standalone 16-bit compilation option (
    I think it lacks ADT.

    What do you think of it ?

  • Joe Barnes says:

    I was unaware of the potential for Rust as an embedded system language. It will be interesting to see how that aspect comes along compared to Erlang whose flagship application runs embedded on a switch. Nice post!

  • Evan Byrne says:

    I remember checking out rust right when it was first released, but I forgot about it rather quickly. I’m glad I ran into this blog post, because it has reintroduced me to the language. It looks very promising and I can’t wait to see it mature to the point where it’s safe to use in production!

  • brianoh says:

    Yes, I think Rust looks VERY interesting. I also have been searching for a language that suites ME. The two that are currently on my radar are Rust and Go. The advantage IMHO that Go has is that it is very simple to program (conventional). Go also from my limited experience is safe – it’s hard to create buggy code. Rust MAY have the edge in performance and no GC. Perhaps Go should/could make GC optional. I almost hate myself for not just going with Go. What is it I dislike? The only thing that comes to mind is – it looks a little old. It also appears very hard to create buggy code with Rust – perhaps even moreso than Go.

    The Go IDE (Liteide) although Ok, looks old, and that makes the language look old. Now, if they had an IDE similar to Dart, then why would one look elsewhere? That is despite the fact that the Dart IDE is built on Eclipse (I still don’t believe that :)). We try to create perfect programs, and therefore we need a perfect language to do that. Google/Mozilla/… require a gr8 language and it will save Goog many millions to use Go. Mozilla on the other hand require a low-level language that is fast and safe and without a GC (or optional). Competition can be gr8, but oligopolies are not. Goog is obviously the larger player, however that can be a positive (present tense), or a negative (future tense). Goog is impinging on our privacy too much IMHO. The bean-counters have stepped-in.

  • Comments are closed.