What would you present to C++ developers interested in Rust?

105 points VorpalWay

At my dayjob (C++) I recently got a request to present about Rust to my collegues.
The presentation would be a mix of "why is Rust great" and concrete examples showing that.

Some context: We use C++ for hard realtime (some parts of the system) and not-so-hard realtime
(other parts of the system) control of heavy industrial vehicles.
We also have various support systems (such as back-office planning and fleet monitoring systems, etc).
We also have python for a whole system integration test framework, so most devs are at least
somewhat familiar with basic Python (though not experts in it). As a GUI framework we use Qt, and
we communicate with various devices over CAN and Ethernet (in a way, this is similar to a car,
just much slower and much much heavier). The code is structured around the actor model and
program-internal pub-sub.

What would you present as the most important features of Rust to such a crowd? I'm thinking
about both briefly highlighting the similarities (RAII, lambdas, no GC, curly bracket syntax, etc) as well as
then focusing on the (cool) differences:

  • Result & Option
  • Pattern matching
  • Ownership & borrowing and how that enables finding bugs at compile time
  • Unsafe/safe and how that limits where you have to look for bugs
  • Traits vs inheritance (we use lots of interfaces but usually very shallow inheritance, outside the Qt code, so I don't think this is too hard of a sell)
  • Macros and how it can reduce boilerplate
  • Cargo and how having an actual package manager is great (we are currently transitioning from cmake to bazel on the C++ side of things)
  • A standard library that is actually consistently thought out and well designed (I'm having some throuble coming up with examples here, it is more of a general feeling I get when using both languages)

The goal of the talk is not to teach Rust (at this point, we do have a small experimental project
for the back office already testing that), but to get a wider group at the company interested,
and show them why it might be interesting.

That also means being honest about the limitations:

  • FFI with C++ won't be easy, better to split things into separate programs and use IPC/RPC
  • Object soup code will be harder to write, as will some other patterns
  • The ecosystem is evolving rapidly, some libraries may not exist or be all the way there yet.

Any advice or ideas would be greatly appreciated!