Small Bytes: Rust (Premium)

Even non-programmers have likely heard of Rust, a programming language that’s taken the developer world by storm. If not, consider the most recent Stack Overflow Developer Survey, which notes that Rust is the most loved programming language among its respondents for the 7th year in a row: “87 percent of developers say they want to continue using it,” the survey explains. “Rust also ties with Python as the most wanted technology, with TypeScript running a close second.”

Or consider that Linus Torvalds and the other maintainers of the Linux kernel have decided to make Rust the first programming language not named C to be used in their work. The Linux 6.1 kernel, released just last month, is the first to incorporate Rust code. Granted, it’s early days, and the Rust compiler used on Linux apparently needs some work, but the conservative maintainers of the kernel apparently think so much of Rust that they are moving forward anyway. The goal is a world in which all new Linux kernel code is written in Rust.

So what’s the attraction?

It all comes down to code safety. While C and Rust are syntactically similar---Rust is one of far too many C-like languages, as I think of them, or “curly braces languages,” as others might say---they couldn’t be further apart when it comes to writing safe code. Safe code is code that doesn’t---cannot---improperly handle memory. A situation that leads to approximately two-thirds of all security vulnerabilities.

Put another way, C is a powerful language that puts the onus of writing safe code on the developer, while Rust is a powerful language whose compiler and coding tools ensure that code written by the developer is safe. And it does so without the overhead that usually accompanies this type of advance. For example, C# code is described as “managed code” because it runs within the .NET runtime, which runs on top of whatever OS the user has. But the Rust compiler, like that of C, generates native code that runs directly on the OS. So there’s no performance tradeoff for the safety features it provides.

For most applications, the performance tradeoff of garbage collection and the other advantages of .NET and other runtimes is not noticeable, especially in this age of powerful computers and devices. But those turning to Rust have other, more low-level concerns where this tradeoff is unacceptable. They’re writing drivers, perhaps. Or OS kernels, as with Linux. And last week, we learned that Microsoft is adding Rust support to its Azure Sphere Internet of Things (IoT) platform.

Rust is cross-platform and works across Windows, Mac, and Linux. It’s extensible via third-party libraries, which are called crates, many of which are exactly what you’d expect: native API wrappers for common libraries and frameworks. Claiming that Rust is having a moment is understating the appeal: the C code that runs the planet will never disappear, but after many false starts at replacing C---...

Gain unlimited access to Premium articles.

With technology shaping our everyday lives, how could we not dig deeper?

Thurrott Premium delivers an honest and thorough perspective about the technologies we use and rely on everyday. Discover deeper content as a Premium member.

Tagged with

Share post

Please check our Community Guidelines before commenting

Windows Intelligence In Your Inbox

Sign up for our new free newsletter to get three time-saving tips each Friday

"*" indicates required fields

This field is for validation purposes and should be left unchanged.

Thurrott © 2024 Thurrott LLC