Image: SARINYAPINNGAM, Getty Images/iStockphoto

Rust has no right to be as sexy as it is. After all, it’s a low-level programming language that touts “safety is our number one priority,” as if it were an airline or something. Even so, Rust has rocketed to the top of the programming language popularity charts, sitting just outside RedMonk’s top 20 for the third quarter plot for 2019 at #21, leading RedMonk analyst Steven O’Grady to write, “For a systems language to continue its upward trajectory in this fashion suggests that some combination of the design, the language’s community and market demand is combining to have it outperform its natural expectations.”

While O’Grady identifies a few key selling points for Rust, Cliff Biffle’s 2019 post goes one step further in illustrating why a C/C++ developer might fall in love with Rust.

SEE: Rust: What developers need to know about this programming language (free PDF) (TechRepublic)

What C++ aspires to be

Biffle has spent years optimizing C++ code to run a complicated microcontroller graphics demo. Given years of optimizations, why futz with Rust? Because, he said, “most of the common security/reliability bugs we see in software today are a result of flaws in the C and C++ languages.” Rust, as a safety-first language, promised to reduce or eliminate the bugs while delivering the performance of a true systems language.

Promised, sure. Delivered? Absolutely. Biffle wrote, “The Rust implementation is simpler, shorter (in lines of code), faster, and smaller (in bytes of Flash) than my heavily-optimized C++ version–and because it’s almost entirely safe code, several types of bugs that I fought regularly, such as race conditions and dangling pointers, are now caught by the compiler.” That’s a pretty strong endorsement.

He goes on to identify four other areas where Rust trumps C++:

  • The Rust tools and library ecosystem are fantastic. Simply having a package manager is an incredibly important advance.

  • When I am writing C++, I’m thinking about undefined behavior and bugs the compiler won’t catch. When I’m writing Rust, I’m thinking instead about how to optimize things or add features. There is a very real cognitive load difference and it makes me more productive.

  • Rust’s safety features, such as bounds checking, have caught bugs and have not caused performance problems….

  • The port revealed significant subtle bugs in the C++ code when the Rust compiler wouldn’t let me do certain things…that turned out to be legitimately incorrect things to do.

Nor is Bizzle alone in his enthusiasm for Rust.

SEE: Rust: What it is, why you should learn it, and how you can master it (free PDF) (TechRepublic)

A growing chorus of praise

In a conversation with Oso CTO Sam Scott, he commented on how Rust allows you to go deep in systems programming without easily getting lost:

[Rust] fe[els] like systems programming with guard rails. All the things I needed to do low-level systems programming, but with a lot of help to debug and to make the code safe–like the borrow checker and compiler, and then later on tooling like the linters (“clippy”). It had offered a lot of the familiar aspects of functional and object-oriented programming, and just seemed to fit with my mental model of how I wanted to build systems.

Developer David Barsky is no less effusive in an interview, calling out, among other things, the ways that Rust improves developer productivity: “Cargo, the build tool and package manager, is one of the best build systems and package managers I’ve used. Rust also comes with excellent built-in documentation, and great, built-in unit, integration, and documentation testing.” This, combined with Rust’s superior performance (“For latency-sensitive network services, Rust’s lack of runtime garbage collection results in almost non-existent tail latencies,” noted Barsky) make it a language worth getting to know.

If you’ve wanted to experiment with a systems language but have shied away due to perceived (or actual) complexity, give Rust a try–it might be the open source upgrade on C/C++ you’ve been waiting for.

Disclosure: I work for AWS, but nothing herein relates to my employment there.