View on GitHub

Rust, the good, the bad, and the ugly

Material for a training session on Rust

The Rust programming language has gained quite some attention as a systems programming language with strong safety guarantees. What are its strong points, its weak points? Is it a practical language for scientific computing and data analysis? Should you learn it, use it?

This training tries to give you some insight into the language and how it compares to other programming languages used in scientific computing, such as C, C++, Python, Julia, R, and Fortran, so that you can answer these questions for yourself.

Learning outcomes

When you complete this training you will

Schedule

Total duration: 4 hours.

Subject Duration
introduction and motivation 10 min.
project workflow and scalar computation 35 min.
control flow and program structure 25 min.
ownership, borrowing, and mutation 45 min.
coffee break 10 min.
structs, traits, and iterators 45 min.
error handling, testing, and reproducibility 30 min.
parallelism and integrated examples 30 min.
Rust ecosystem 20 min.
wrap up 10 min.

Training materials

The learning modules are available as a website.

The slide deck is available as a Quarto RevealJS presentation.

The source code, slide sources, and learning-module Markdown files are available in the GitHub repository.

Target audience

This training is for you if you want to learn enough Rust to judge whether it could work for scientific computing, technical software, data-processing tools, or command-line applications.

Prerequisites

You will need experience programming in some programming language such as Python, Julia, R, C, C++, or Fortran. This is not a training that teaches you how to program.

If you plan to use Rust in a Linux or HPC environment, you should be familiar with these as well.

More concretely, participants should already be comfortable with the following:

You do not need prior experience with Rust itself, ownership and borrowing, traits, Cargo, Rayon, or Rust’s scientific-computing ecosystem. Those are part of the training itself.

Quick self-assessment

If you can do most of the tasks below in some programming language, you are likely ready for this training.

If several of these items still feel difficult, the training will probably move too fast. In that case, it is better to first take a short introductory programming course.

Software and access requirements

To follow hands-on, you need a computer with a Linux-style terminal and a Rust development environment installed. The recommended setup uses rustup for the Rust toolchain and cargo for building and running the examples.

Some examples use Python helper scripts for visualization, and the learning module website is built with MkDocs. The repository contains an environment.yml file for creating the Python environment with mamba.

See the repository’s SETUP.md file for installation and verification commands.

Level

These percentages describe the level of the Rust and scientific-computing topics covered in the training, not the participants’ general programming background.

Trainer(s)