A Brief Introduction to Rust

Learn the basics of Rust programming with this introduction for R developers.

Last updated:

Want to build Rust powered R packages but don’t know where to start? These tutorials will walk you through the basics of Rust programming using familiar R concepts.

Why Rust? 🦀

Unlike interpreted languages like R and Python, Rust is a compiled language. That means it can often be much faster and more efficient, similar to other compiled languages like C or C++. But where those compiled languages can be hard to use and easy to break, Rust was built to be both safer and easier to work with. Rust is also designed with developers and developer experience in mind. No where is this more evident than in the quality of Rust’s error messages. 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 Installation Guide 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.