Articles on Rust

Last updated: 2023/01/19

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.

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.

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).

Reading and writing, part 2: files and databases

Working with databases can be tricky business. When it comes to SQL, you'll often have to use transactions for complicated queries, because they might consist of multiple queries, business logic, and then updates or inserts, which require all the data for that transaction to be unchanged (ie not have some other update query change the value of something before the transaction is finished). In this extensive article, James Coglan demonstrates how reading and writing to a database record can be handled to reduce these kinds of issues,  and some solutions for allowing limited database access when data is being worked on.

Reinforcement learning, non-Markov environments, and memory

Reinforcement learning is basically teaching a machine learning model to produce a result based on environment variables it has access to. It involves some complicated sounding, but fundamentally simple probability jargon. Jan Corazza's article, luckily, covers the basic topics better than I can, and then dives into exploring the limitations of of the Markov property. Jan provides a solution to the problems he discovered implemented in 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.

Building a WebAssembly-powered serverless platform

Colin Eberhardt demonstrates how to setup your own serverless platform using Web Assembly and 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!

Building a BFT JSON CRDT

CRDTs are a family of data structures that are used to replicate data across multiple computers. They are designed to avoid conflicts when people write data to the same place.
Some highlights:

  • CRDTs mathematically guarantee that an application can safely update their local state without needing to coordinate with all of its peers
  • Traditional databases focus on a property called linearizability, which guarantees that all operations behave as if executed on a single copy of the data
  • CRDTs can be made fault tolerant by solving a problem called the Byzantine Broadcast

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.

RAII: Compile-Time Memory Management in C++ and Rust

Jimmy Hartzell discusses how Rust's RAII-centric compile-time memory management system compares to other run-time reference counting and garbage-collection technologies.
Some highlights:

  • RAII was originally designed to solve the problem of managing resources, and while it has some deficits, C++ has added features like move semantics and opt-in reference counting that help to close the gap
  • The biggest downside of the above memory management techniques is the performance implications and handling of cyclic data structures

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.

Pointers Are Complicated III, or: Pointer-integer casts exposed

Ralf Jung demonstrates how compiler optimizations related to pointer to integer casting can result in unwanted behavior.

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.

Backdooring Rust crates for fun and profit

You know what they say, the best defense is a strong offense! Well in the case of infosec, this is a relatively new approach. In this dangerous article, Sylvain Kerkour presents several methods for hiding and executing backdoor code in Rust crates.

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"

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.

CDN Up and Running

Leandro Moreira discusses the various components that go into building a CDN, including nginx, lua, docker, docker-compose, Prometheus, grafana, and wrk.
Some highlights:

  • CDN helps improve load times for content, reduces costs, and removes some major scalability issues
  • Includes lots of information on how to monitor your CDN service
  • Overview of challenges and trade-offs of building, managing, and operating a CDN

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

Request coalescing in async Rust

Amos dives very deeply into setting up a custom web server in Rust using the async runtime.

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.

Why Rust mutexes look like they do

Cliff L. Biffle compares Rust mutex API design to C, and explains why the latter is fundamentally inline with core Rust principles.

Want to see more in-depth content?

subscribe to my newsletter!

Other Articles