Rust: productivity for resource-constrained implementations

Deploying state-of-the-art research on tiny devices is a challenge. Connecting conceptual research with practical hardware requires tools that handle both sides of the equation efficiently.

Rust is a technology that I believe will make an impact by bringing productivity-enhancing tools close to metal, and by making deployment easier to teach.

As the unit of Computing Sciences, our key challenges are to teach the top experts in software engineering and to make software development and implementations efficient. Part of that challenge is to learn how to teach students to create efficient implementations. Rust is a potential solution for this.

Rust is a new programming language that is not for everyone. As a systems programming language, it is hard to learn because it asks the programmer to understand how computers work in exchange for speed and reliability.

Snapdragon 835 HDK and the STM32F103 microcontroller: two of the platforms we’ve run Rust on.
Snapdragon 835 HDK and the STM32F103 microcontroller, two of the platforms we’ve run Rust on.

While a high-level language featuring garbage collection is still the best choice for many applications, Rust is significant in that it brings staple academic research into a language that fits into low-level use cases. Affine type systems, region based memory management and static prevention of data races may or may not sound awesome depending on your background, but they make inherently complex software less likely to contain errors and easier to read and create. These are technologies that have not been readily accessible to developers of resource-constrained software, cybersecurity solutions and IoT. Like C, Rust runs natively on platforms ranging from mobile phones to ARM Cortex-M microcontrollers while providing the tools to both move to a higher level of abstraction and to talk directly to C or assembly.

Source code showing an asynchronous get request to google.com in Rust.
Affine types in action: Rust code to make an asynchronous GET request to google.com. The second call to `await?` is illegal because the type is consumed by the first call, preventing misuse of the API.

If we are to considerably improve productivity and automation of software development, we could use these innovations in our future software ecosystems: software libraries, accelerators, data centers and edge devices. Rust is a niche language, it’s very much the niche where our university is looking to make an impact.

Yet the path from a research language to an industry accepted low-level language is riddled with hardship. Full parity with C is expected, as outlined by Intel principal engineer Josh Triplett in his talk “Intel and Rust: The Future of Systems Programming”. This obstacle alone has barred most modern languages from entering the domain of low-level programming, leaving programmers to (ideally) rely on careful manual memory management, robust testing practices and well documented interfaces for correct and uncompromisingly fast implementations.

While being still slower to compile, Rust is not hindered by sub-C performance. Correctness guarantees at demanding conditions, and the ability to interface and defer to C allow Rust to compete in the market where the previous best technology available was created almost 50 years ago.

So what has changed in 50 years in systems space? Memory safety, affine types, functional programming, type inference, pattern matching, package management and language level support for safe, concurrent programming. In other words, no Heartbleed, no segfaults or use-after-free, API programming with no side effects, automatic type annotations, dependency management that encourages use of other people’s code and a programming model that is parallelizable by default.

Source code showing a crafted example of a robot arm controller, demonstrating a possible API for reading the results from an asynchronous algorithm and acting on the results using pattern matching.
A crafted example of a robot arm controller, demonstrating a possible API for reading the results from an asynchronous algorithm and acting on the results using pattern matching. Grey text is visualization added by the development environment.

Beyond that, the community response to Rust seems somewhat unanticipated of a hard-to-learn, low-level language. Rust has been voted as the most loved language for 4 years in a row in StackOverflow developer survey, showing a notable enthusiasm for the language from the overall developer community.

I believe that is ultimately because Rust empowers more people to productively access and understand that which used to be arcane for many while helping experts create high-performance implementations. The language’s learning materials can help a relative novice to get a grasp on complex topics like embedded programming, operating systems and hardcore low-level optimization. While Rust has provided a starting point for many who are interested in low-level optimization, professionals and open-source contributors have gone on to accelerate everything from standard Unix tools to web services to data centers.

Due to its potential to increase productivity at the foundation of software, many of the future experts we teach will learn Rust and go on to apply the language in their projects to improve speed, safety and productivity.

Comments

Leave a Reply

Processing comments...

Your email address will not be published. Required fields are marked *