Articles on Rust

Last updated: 2023/03/09

Top deep-dives on Rust

The Adventures of OS: Making a RISC-V Operating System using Rust

RISC-V is one of the few (if not the only) open source instruction set architectures, and was created by academics to be viable for education, research, and practical use. In this series of articles, Stephen Marz gives a detailed outline with instruction on creating your own operating system with Rust and RISC-V.

Dissecting Deno

Who let the Deno out? Who, who, who, who, who? Ryan Dahl, the original creator of Nodejs, did and with the goal of improving on all of the mistakes made with Node. In this extensive article, Stefan Baumgartner explores how the Deno runtime is setup in Rust compared to other JavaScript runtimes, highlighting key differences like Deno's pattern of extending browser APIs.

Making Reasonable Use of Computer Resources: Part 2

As you sit at your desk, scratching your head thinking about how you could shave a few seconds off of the function you just wrote, you hear a faint whisper in the wind, "premature optimization is the root of all evil". Well if your function takes days to run, it's definitely not premature. In this short article, the author describes the steps taken to optimize a JSON parsing script that originally took "more than a day to run", down to about 15 minutes using some clever shortcuts.

The curse of strong typing

Amos does an extensive coverage of types in Rust.

A terminal case of Linux

Sometimes you can fall into a deep rabbit hole when you're exploring how a programming tool works. Well this article by Amos does so in an exceptional way. Amos starts out trying to print JSON in a Linux terminal with colors, and ends up writing a Rust program.

One Hundred Thousand Lines of Rust

If you start writing an application that somehow ends up being 10,000 or 100,000 lines of code, your earlier mistakes might come back to haunt you. An easy way to help reduce the chances of that is to learn from the mistakes of others! In this extensive series, Aleksey Kladov articulates the importance of an architecture file, highlights how integration and unit tests are implemented in Cargo, describes his approach to testing, brings forth tribal inline attribute knowledge, advises on organization, and promotes fast build times.

Post #0: In Which I Set Out to Write a Terrible Compiler for a Useless Language

What better way to start the new year than with an exploration of some low level programming? In the first article of this series, the author goes through what it takes to print to the command line with assembly and writes a compiler in Rust that produces quines.

Let’s build an LC-3 Virtual Machine

A virtual machine is pretty much another computer running inside of your computer's system. One excuse to build them from scratch is to better understand how computers work. Rodrigo Araujo's extensive article was created for just that reason, and Rodrigo does an excellent job of explaining those gnarly bits that leave you scratching your head (like unexplained bitwise operations).

Overhead of Returning Optional Values in Java and Rust

How does one turn the idea of nothing into something physical? Well Alex, you say in your most pedagogic inner voice, isn't that what 0 is? Well dear reader, it's probably up to the individual, but null is one of the more common methods. Piotr Kołaczkowski's article however, focuses on an alternative to null, the Optional or Maybe type. Piotr specifically focuses on the performance impact of using this type, as opposed to primitives, in both Java and Rust.

Self Modifying Code

Aleksey Kladov demonstrates how one can generate source code without using macros in Rust, but with concepts that apply to other programming languages as well.

Xilem: an architecture for UI in Rust

Raph Levien introduces a new UI framework for Rust that's powered by synchronized trees.

Rewriting The Modern Web In Rust

Kevin King walks through rewriting a personal website using Next.js, React, tsx, and mdx, to a full-stack Rust alternative.
Some highlights:

  • Yew and Axum to build a single-page application with server-side rendering, Hooks, Markdown, and code syntax highlighting
  • Tailwind can be used in Rust files
  • Overall the Rust full-stack ecosystem has come a long way, but it's still not close to being ideal

Rust data structures with circular references

Rust's marvelous memory safety system comes at a cost; it's kind of a pain to implement data structures that have circular references. In this exploratory article, Eli Bendersky tries several different approaches for implementing structures that have circular references (like binary search trees).

Rust concepts I wish I learned earlier

Raul Jordan explores some of the trickier concepts in Rust that are worth learning when picking up the language.
Some highlights:

  • "There are two kinds of references in Rust, a shared reference (also known as a borrow), and a mutable reference (also known as an exclusive reference)"
  • Implement Deref to make your code cleaner
  • Really annoyed by the borrow checker? Use immutable data structures

Exception safety in Rust: using transient droppers to prevent memory leaks

In Rust, exception safety is defined as "being ready for unwinding". But that isn't the clearest explanation.  Arthur Carcano has written an article that essentially explains exception safety in Rust and how it can be achieved, in the context of array initialization.There's plenty of code to show what is being talked about.

Contexts and capabilities in Rust

"Very often in programming we find ourselves needing access to some context object in many places in our code". In this exploratory article, Tyler Mandry presents a solution for declaring contexts in Rust that can be provided by the compiler.

Teleforking a process onto a different computer!

Tristan Hume presents a demo project for streaming a Linux process to a remote system for execution.

Implementing truly safe semaphores in rust, and the costs we pay for safety

Mahmoud Al-Qudsi discusses the concept of "zero-cost abstractions" in programming, which is the idea that abstractions should not incur any additional runtime cost. The Rust programming language is used as an example of a language that embraces this concept. Mahmoud goes on to implement a semaphore type in Rust.

The Rust borrow checker just got (a little bit) smarter

Jack Huey discusses how "the NLL borrow checker finally got fully enabled by default" in Rust and how it affects you.

One funny way to bundle assets

Amos shows how to bundle files for a Rust application using a build script. Wow!

A prioritised micro-batch scheduler in rust

How do you solve an issue where real-time calculations are holding up access to your database? In this article, Mike Bush discusses how he was able to resolve it at his company by building a micro-batching scheduler library in Rust.

When rustc explodes

Amos explores reducing compile times for Rust.

TypoSquatting, RepoJacking, and Domain Takeover – The Story of the Recent Attacks

Alex Ilgayev covers three recent incidents involving malicious packages in the Rust and Python ecosystems.

Async overloading

Another article along the lines of APIs, this time Yoshua Wuyts explores how async operations are handled in different languages, as inspiration for coming up with a standard for Rust. Yoshua uses the recent Swift async overaloading amendment as a template for a similar implementation in Rust, and concluding with a number of caveats.

Generate All the Things

Property based testing is when you test a general property of an output. It's been popularized in Haskell by the QuickTest framework. In this article however, Aleksey Kladov focuses on a specific step for property testing; "how to conveniently enumerate any kind of combinatorial object without using recursion" in Rust.

Rust PNG writer from scratch

Chris Hulbert presents a short program for writing generating PNGs in Rust.

Caches In Rust

Aleksey Kladov implements a cache in Rust and highlights some of the nuances along the way.

Async Cancellation I

I guess today is an async kind of day huh? As Yoshua Wuyts correctly surmises "sometimes we start things but decide midway through that we would prefer to rather not be doing them". How would this kind of functionality be done in Rust? Yoshua's article first distinguishes between tasks and futures, then goes on to explain how cancellation propagation should work for both, how it can be backported, how to reason about structured concurrency, and much more.

How Bevy uses Rust traits for labeling

Bevy is a game engine written in Rust. In this article, Pascal Hertleif describes Bevy's basic usage philosophy and how you can "type" things using labels.

Rust Any Part 1: Extension Maps in Rust

"Sometimes in Rust you want to design APIs that provide a little bit of flexibility for the user". In this first part article, Armin Ronacher presents how one can do that using the Any type to get around complexities inherent in the traditional method of using generic type parameters.

Production Twitter on One Machine: 100Gbps NICs and NVMe are fast

Tristan Hume explores how different features of twitter would work if the entire service was run on a single, very powerful machine.
Some highlights:

  • First step is calculating what kind of load needs to be handled, based on real twitter stats
  • If that one machine dies, you're screwed
  • Pricing data is included for the fantasy system

The Registers of Rust

In the article, Saoirse Shipwreckt talks about the idea of "registers" (using language differently in different circumstances) in programming languages.
Some highlights:

  • Looks at registers for asynchronous code in Rust
  • ^ is missing the iteration and fallibility registers
  • Ponders on what good design choices are

Rudra: Finding Memory Safety Bugs in Rust at the Ecosystem Scale

Rustaceans pride themselves on the memory safety of Rust. Many a times I've heard them say, "Rust just won't allow you to make mistakes". That might be the case most of the time, but sometimes you have to go into unsafe mode, which suspends some of the stringent memory rules. In this informative article, Micah Lerner covers a paper that outlines "Rudra, a system for finding memory safety bugs in code written with the Rust programming language". Micah briefly describes Rust's memory management system, then dives into the design, implementation, and evaluation of Rudra.

Simple Scalable Unbounded Queue

Protty describes the properties of channels and how they are categorized. The author then goes on to talk about their implementation of an Unbounded, Non-Blocking, MPSC (Multi-Producer Single-Consumer) channel.
Some highlights:

  • "a 'channel' refers to a type of queue generally used in a programming language for passing data from one concurrent task to another with extra amenities"
  • Bounded or Unbounded describes whether or not the channel has a maximum capacity of stuff it can have in it which hasn't been dequeued
  • "Blocking channels will pause the caller until it can interact with the channel whereas non-blocking channels will return immediately with some sort of error"

Solving Jigsaw Puzzle with bare Rust

Borys Minaiev has written two articles on solving a mostly white jigsaw puzzle with software (Rust).
Some highlights:

  • Presents a rough plan to solve the problem
  • Implements the plan, but finds issues with it
  • Attempts to solve the issues and ends by taking up the challenge to the next level

Undefined behavior, and the Sledgehammer Principle

JeanHeyd Meneide explains the implications of GCC optimizing code in a way that can result in undefined behavior.
Some highlights:

  • "Yodaiken argues in his blog that Undefined behavior being used for optimization is simply a “reading error”"
  • This is not the first time the C Language, implementations, or the C Standard came under flak for this kind of optimization
  • The issue is signed integers triggering undefined behavior on a left shift

Garnet: The Generics Problem

Simon Heath discusses the problem with generics and how it relates to code reuse, in reference to implementation on the Garnet programming language.
Some highlights:

  • Although generic types aren't complicated to implement by themselves, the complexity comes up when you want to start reasoning about the relationships between types, including types you don't know about yet
  • Modules trade off some power for simplicity
  • The main practical difference between traits/typeclasses and modules is that with traits the compiler does more of the accounting work for you

Hooking Go from Rust - Hitchhiker’s Guide to the Go-laxy

Aviram Hassan and Mehul Arora cover how to hook into Go functions using Rust.

A Look at dyn* Code Generation

Eric Holk presents the new experimental type called dyn* being added in Rust that will give the language more flexibility to support dynamic dispatch for async methods.
Some highlights:

  • The aim is to be able to support async functions everywhere in Rust, including in trait objects
  • A trait object is an opaque value of another type that implements a set of traits
  • dyn* should not impose significant costs above what’s already incurred by dyn

Mononym: Type-Level Named Values in Rust - Part 1: Demo and Implementation

"Mononym provides the core type Named, which represents a named value of type T with a unique type N as its name". From my understanding, this allows one to create proofs in Rust that are type safe, enabling one to better implement functional programming methods. In this introductory article, Soares Chen demos how the Mononym library can be used, then goes on to discuss the technical details of its implementation.

Rust vs C++ Formatting

In short, Barry Revzin compares the formatting abilities of Rust to those of C++.
Some highlights:

  • Rust has various ergonomic features that make it easier to format strings
  • Rust has multiple different formatting traits
  • Implementing static reflection and interpolated literals from Rust, in C++ could lead to good improvements for formatting in the latter

RPATH, or why lld doesn’t work on NixOS

Aleksey Kladov explains how NixOS' directory structure breaks building Rust code with LLVM's dynamic linker.

Diving Deep: implied bounds and variance

lcnr presents an unsound issue in Rust where a function can arbitrarily transmute lifetimes, causing a segmentation fault, and explores possible solutions.

piet-gpu progress: clipping

Raph Levien explains how the computation of path clipping for piet-gpu (a new compute-centric 2D GPU renderer) was fully transferred to GPU from CPU.

Reflecting on Transducers

Jeremy Steward explains his process of creating a transducer egg (module) for Scheme. Jeremy was motivated to create the egg because they wanted Scheme to have something similar to Rust's iterator trait.
Some highlights:

  • Tranducers are a way to apply a composition of functions to each element in a collection
  • Creating something like a trait in Scheme is difficult, because Scheme is a dynamic language
  • Scheme library authors aren't really helping the idea that lists should only be used in certain circumstances and not all of the time

Speeding up Rust semver-checking by over 2000x

Predrag Gruevski highlights "how cargo-semver-checks will benefit from the upcoming query optimization API in the Trustfall query engine".
Some highlights:

  • "Today, cargo-semver-checks is good enough to prevent real-world semver violations, and fast enough to earn a spot in the release pipeline of most crates"
  • Checking larger crates is slow though
  • Indices are used to speed things up!

Optimizing AWS F1 DMA

Tony Wu discusses a pain point that occurs "when transferring large amounts of data from a software application running on a typical x86 host machine to an FPGA for accelerated computation".
Some highlights:

  • "Multi-Scalar-Multiplication is one of the major computational bottlenecks at the core of many Zero-Knowledge-Proof systems"
  • "Xilinx/AWS provides a Linux-based driver running in kernel space that manages the low-level configuration of the DMA hardware on the FPGA"
  • "Using CPU cores to transfer data usually has low latency, however it is very inefficient for large amounts of data and can result in low performance, so we would much rather use a DMA for the task"

Want to see more in-depth content?

subscribe to my newsletter!

Other Articles