A Brief Introduction to Rust
Want to build Rust powered R packages but don’t know where to start? This guide will walk you through the basics of Rust programming using familiar R concepts.
Why Rust? 🦀
Unlike R and Python, which are interpreted languages, Rust is a compiled language. That means it can often times be much, much faster and more efficient, similar to other compiled languages like C or C++. But where those languages can be hard to use and easy to break, Rust was built to be safer and more helpful. Rust is especially good at preventing bugs related to memory. There’s no garbage collector in Rust, so it is quite memory efficient. Moreover, Rust is designed with the developer in mind. The Rust compiler provides error messages that rival — or maybe even surpass — the quality of tidyverse error messaging.
Prerequisites
This introduction is designed for intermediate R developers who are familiar with fundamental computing concepts, including data types (like floats, integers, and booleans), iteration (with for and while loops, purrr::map() style iterators, and the apply() family of functions), control flow, and functions. Being comfortable with a terminal environment will be helpful, too.
Regardless of whether you meet those prerequisites, you may find it helpful to freshen up on your R fundamentals by reading or reviewing the following materials:
As for Rust, a lot of the materials in this brief introduction come from the official guide, The Rust Programming Language, what Rust developers affectionately call “The Book.”
Software requirements
This guide assumes that you have Rust 1.65.0 installed. Please see Get Started if you do not.
If you are not yet comfortable with installing Rust, you may find it helpful to try out examples in this tutorial using the open source Rust Playground browser app.
Acknowledgment
These introductory tutorials are based on the Rust for R Developers workshop led by Josiah Parry at the 2025 Cascadia R Conference.