Rust

Rust, the memory-safe systems language: history, how ownership works, why AI infrastructure is moving to it, and how it plugs into Python.

Rust is a compiled systems programming language with the speed of C and C++ and none of their memory bugs. The compiler checks how every piece of memory is owned and shared, so a whole class of crashes and security holes fails at compile time instead of in production.

It has no garbage collector and no runtime to install. It produces a single native binary.

I don't need to write Rust to benefit from it. Much of the Python tooling I use every day already runs on Rust underneath, and that trend is what this note is about.

Type Compiled, statically typed systems language
Creator Graydon Hoare, 2006. Sponsored by Mozilla from 2009
1.0 release 15th May 2015
Current version 1.99.1 (15th October 2026). A new stable release ships every 6 weeks
Current edition Rust 2024 (since 1.85, February 2025)
Governance The Rust Project teams, funded by the Rust Foundation since February 2021
Licence Dual MIT and Apache 2.0
Toolchain rustup (installer), cargo (build and packages), crates.io (registry)
Mascot Ferris the crab. Rust developers call themselves Rustaceans

The video: why AI infrastructure is moving to Rust

This 6-minute explainer from Byte Without Bite (15th October 2026) gives the clearest short answer I've seen to a question I kept asking: if Python runs AI, why does every new AI tool say "written in Rust"?

Its thesis fits in 1 line: Rust isn't replacing Python in AI. It's replacing the C++ underneath it. The rest of this note expands on that, with the video's points folded in where they belong.

Short history

  • 2006, a broken lift. Graydon Hoare, a Mozilla programmer, started Rust as a personal project after the software in his building's lift crashed once too often. Memory bugs in C and C++ code were the cause he wanted to design away.
  • 2009, Mozilla. Mozilla sponsored the project and wanted a safer language for a new browser engine, Servo. Parts of Servo, including the Stylo CSS engine, shipped in Firefox Quantum in 2017.
  • 2015, 1.0. Rust 1.0 came out on 15th May 2015 with a stability promise: code written for 1.0 still builds on today's compilers, with rare exceptions.
  • 2016 onwards, most admired. Rust has topped the Stack Overflow developer survey as the most loved, now "most admired", language every year since 2016. In 2025 it scored 72%, its 10th year in first place.
  • 2020 to 2021, the Rust Foundation. Mozilla laid off much of its Rust team in August 2020. AWS, Google, Huawei, Microsoft and Mozilla then founded the Rust Foundation in February 2021 to fund the project.
  • 2022 to 2025, Linux. Linux 6.1 (December 2022) accepted Rust as the 2nd language of the kernel, as an experiment. In December 2025 the kernel maintainers ended the experiment: Rust stays. Android 16 already ships a Rust memory allocator in its kernel.
  • 2024, governments. The US White House cybersecurity office (ONCD) asked the software industry in February 2024 to move to memory-safe languages, and named Rust.
  • 2026, AI tooling. GitHub ported the GitHub Copilot runtime from TypeScript to Rust (more on this further down).

The name. Hoare has said he named it after the rust fungi, organisms he described as "over-engineered for survival". The jokes about a "robust" substring and oxidised metal came later.

Key features

Ownership and borrowing

This is the idea that makes Rust different from every mainstream language.

  • Every value has exactly 1 owner.
  • When the owner goes out of scope, Rust frees the memory at that exact point. No garbage collector, no manual free().
  • Other code can borrow a value: many readers at once, or 1 writer alone, never both.
  • The borrow checker enforces these rules at compile time. Code that breaks them doesn't compile.

The result: no use-after-free, no double-free, no null-pointer crashes in safe code, and no data races between threads.

The other features

  • Zero-cost abstractions. Iterators, generics and closures compile down to the same machine code as a hand-written loop.
  • Fearless concurrency. The type system marks which data is safe to send or share between threads (Send and Sync). A data race is a compile error.
  • No null, no exceptions. A missing value is an Option. A failure is a Result. The compiler forces you to handle both.
  • Cargo. One tool builds, tests, formats, lints, documents and publishes. Python never had one tool for all of this. uv is Astral's attempt at a Cargo for Python.
  • Editions. Breaking language changes ship as opt-in editions (2015, 2018, 2021, 2024). Crates from different editions still work together.
  • unsafe as an escape hatch. Low-level code can turn off some checks inside a marked unsafe block. The danger stays small, labelled and easy to audit.

Pros and cons

Pros Cons
C and C++ speed, with memory safety checked by the compiler Steep learning curve. The borrow checker rejects code that "should" work
Predictable latency: memory frees at known points, no GC pauses Slow compile times on large projects
Real parallelism without data races Async is powerful but complex, and split between runtimes (Tokio is the default)
One toolchain (cargo) for build, test, docs and packages Fewer experienced developers to hire than for Python, Go or Java
Small native binaries, easy to embed and to call from other languages GPU kernels still mostly live in CUDA C++, not Rust
Excellent compiler error messages crates.io has the usual supply-chain risks of any package registry

Rust compared with the alternatives

Language Memory model Speed Learning curve Typical use
Rust Ownership, checked at compile C-level Steep Infrastructure, CLIs, engines, kernels
C++ Manual plus smart pointers C-level Steep Game engines, CUDA, legacy systems
Go Garbage collector Fast Gentle Network services, cloud tooling
Zig Manual, explicit allocators C-level Medium C replacement (Ghostty, Bun)
Python Reference counting plus GC Slow, fast through C/Rust libs Gentle Research, scripts, glue code

What makes good Rust code: small functions that borrow instead of clone, errors passed up with ? instead of unwrap(), and unsafe kept to a few audited lines.

For business people

What it is. A programming language for software that has to be fast and must not crash: servers, browsers, operating systems, databases, and now the plumbing of AI products.

The problem it solves. About 70% of the serious security bugs that Microsoft and Google's Chrome team fix each year are memory-safety bugs. These are mistakes that C and C++ let through and that experienced engineers still make. Rust stops them before the software ships.

Proof that it works. Google started writing new Android code in Rust and other memory-safe languages. Memory-safety bugs fell from 76% of Android's vulnerabilities in 2019 to 24% in 2024, without a rewrite of the old code.

Where it fits. Rust usually arrives as a component, not a rewrite. A team keeps its Python or TypeScript product and moves the slow or risky core to Rust. Users never see it. They notice that the tool got faster.

A recent case. GitHub moved the runtime behind GitHub Copilot from TypeScript to Rust between May and August 2026. Their reasons: lower startup cost, predictable resource use, and 1 library that their 6 SDK languages can embed directly, instead of a separate Node.js process per client that cost about 100 MB of memory each.

Cost. The language and tools are free and open source. The cost is people: Rust takes months to learn well, and senior Rust engineers are scarcer than Python or Java engineers.

When to choose it:

  • Long-running services where a crash or a slow reply costs money.
  • Security-critical code: anything that parses untrusted input.
  • Hot spots in a Python product where one function eats most of the CPU.

When not to: prototypes, data analysis, internal scripts and CRUD apps. Python or TypeScript ship those faster, and the speed difference doesn't matter.

For technical people

Ownership in 10 lines

fn length(s: &String) -> usize {   // borrows s, doesn't take it
    s.len()
}

fn main() {
    let a = String::from("hello");
    let n = length(&a);              // shared borrow: a is still usable
    let b = a;                       // ownership moves from a to b
    println!("{n} {b}");
    // println!("{a}");              // error[E0382]: borrow of moved value: `a`
}

The last line is the point. In C++ the equivalent compiles and fails at runtime, maybe months later. Rust refuses to build it.

Errors as values

use std::fs;

fn read_config(path: &str) -> Result<String, std::io::Error> {
    let text = fs::read_to_string(path)?;   // ? returns the error to the caller
    Ok(text.trim().to_string())
}

No hidden exceptions. Every function that can fail says so in its signature.

Calling Rust from Python: PyO3 and maturin

This is the reason Rust spread through the Python world so fast. PyO3 generates the bindings, and maturin builds and packages them as a normal Python wheel.

// src/lib.rs
use pyo3::prelude::*;

#[pyfunction]
fn word_count(text: &str) -> usize {
    text.split_whitespace().count()
}

#[pymodule]
fn fastwords(m: &Bound<'_, PyModule>) -> PyResult<()> {
    m.add_function(wrap_pyfunction!(word_count, m)?)?;
    Ok(())
}
maturin new -b pyo3 fastwords      # scaffold the crate and pyproject.toml
cd fastwords
maturin develop --release          # build and install into the active virtual env
python -c "import fastwords; print(fastwords.word_count('one two three'))"

From the Python side it is a normal import. That is how tiktoken, Pydantic and Polars ship: most of their users never see a line of Rust.

Toolchain commands

Install the toolchain with the official installer. It sets up rustup, cargo and the stable compiler in ~/.cargo:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Command What it does
rustup update Update to the latest stable release
cargo new myapp Create a project with Cargo.toml and src/
cargo run Compile and run (debug build)
cargo build --release Optimised build into target/release/
cargo test Run unit, integration and doc tests
cargo add serde Add a dependency from crates.io
cargo clippy Lint, with 700+ checks
cargo fmt Format the code
cargo install ripgrep Install a Rust CLI tool from source

Gotchas

  • Fighting the borrow checker. Beginners clone everything to make errors go away. That works, but learn borrowing properly, or the speed advantage disappears.
  • Lifetimes. Structs that hold references need lifetime annotations ('a). Store owned data (String, Vec) until you have a measured reason not to.
  • Compile times. Release builds of large projects take minutes. Split code into crates and use cargo check while you work.
  • Async. async needs a runtime, and the ecosystem settled on Tokio. Mixing runtimes causes pain.
  • unwrap() in production. It panics on an error. Fine in a test, a time bomb in a server.

⚠️ WARNING: memory safety covers safe Rust only. An unsafe block, or a C library called through FFI, can still corrupt memory. Audit those lines like C.

Rust in AI: the video's argument

Python is the steering wheel, C++ and CUDA are the engine

The video's core picture: when you train a model, Python orchestrates. One line of PyTorch hands the work to a C++ library, which hands it to a CUDA kernel on the GPU. Python itself does almost nothing.

AI splits into 2 layers:

Layer What it needs Best language
Research layer Try ideas fast, change a model in 5 minutes, readable code Python
Systems layer Raw speed, control over memory, runs for months without crashing C and C++, now Rust

For decades the systems layer meant C and C++. The video's point is that Rust is taking a growing share of that job, for 1 reason above all: C++ compiles memory mistakes without a warning, even with modern smart pointers. Microsoft's and Chromium's 70% figures come from engineers who write careful C++ for a living.

The 4 reasons Rust fits the systems layer

  1. Predictable speed. Python's runtime sometimes pauses to clean up memory. In a notebook nobody notices. In an inference server that answers 1,000s of requests a second, those pauses become slow replies in the slowest 1% of requests. Rust frees memory at exact points, so latency stays flat. As the video puts it, "boring is exactly what you want".
  2. No global interpreter lock (GIL). Python long allowed only 1 thread to run Python code at a time. Rust threads run truly in parallel, and the compiler rejects unsafe sharing. This matters most for data loading: in training, the bottleneck is often the CPU that feeds the GPU, and an idle GPU is expensive.
  3. Control over memory layout. AI moves huge arrays of numbers. Rust controls layout, alignment and allocation as precisely as C++, and gives access to SIMD instructions that process many numbers in 1 step.
  4. It plugs into Python. Through PyO3 and maturin, a Rust library imports like any Python module. Rust never asked the AI world to give up Python.

Where Rust already runs in the AI stack

Tool What it does Rust part
tiktoken OpenAI's tokenizer Core BPE in Rust
tokenizers Hugging Face tokenizers Rust core, Python bindings
safetensors Safe format for model weights Rust core, Python bindings
Candle Hugging Face's minimalist ML framework Pure Rust
Burn Deep learning framework Pure Rust
Pydantic Data validation pydantic-core in Rust since v2
Polars DataFrames, a faster pandas Rust engine
Ruff and uv Python linter and package manager Pure Rust
Qdrant Vector database Pure Rust
LanceDB Embedded vector database Rust (Lance format)

The GitHub Copilot runtime

The video mentions GitHub's move "a month ago". The details, from Stephen Toub's GitHub blog post of 16th September 2026:

  • The runtime behind the Copilot CLI, the Copilot app and the Copilot SDK was TypeScript on Node.js.
  • About 430,000 lines of TypeScript went through the port. The result is about 832,000 lines of Rust plus 469,000 lines of Rust tests.
  • The port took about 14.5 weeks, in 128 pull requests, while GitHub kept shipping (135 releases). The runtime was 100% Rust by 21st August 2026.
  • GitHub did most of the port with Copilot itself, mainly 1 developer. Toub estimates the same job once took a team 1 to 2 years.

Where I'd push back on the video

  • The xAI claim is thin. The video opens with Elon Musk's 2023 prediction that Rust would replace Python for AGI, and says xAI's code is now mostly Rust. The verifiable part is narrower: the X recommendation algorithm that xAI open-sourced in 2026 is Rust and Python, with no Scala left. xAI job ads still list Scala, Go and C++.
  • The GIL is already optional. The video says people are "working on" it. Python 3.13 shipped an experimental free-threaded build in 2024, and Python 3.14 made it officially supported in October 2025. It still isn't the default, and many C extensions aren't ready, so the video's practical point holds.
  • The engine is still C++ and CUDA. PyTorch's core and nearly all GPU kernels remain C++ and CUDA. Rust is winning the layer around them: tokenizers, data loaders, serving, vector search and developer tools. "Replacing the C++ underneath" is true for that layer, not yet for the maths.

Rust in tools I already use

This site already covers several Rust tools, written up before the pattern was obvious:

  • uv, the fast Python package and project manager, see uv
  • yazi, the terminal file manager, see Terminal File Managers
  • llmfit, which ranks local models for my hardware, see llmfit
  • LiteParse, the local document parser rewritten in Rust, see LiteParse
  • WordCraft and the other ArtCraft apps, Office clones in pure Rust, see WordCraft
  • OpenLogi, the open Logitech Options replacement, see OpenLogi
  • Kitesurf, Cloudflare's agent browser, Rust compiled to WebAssembly, see Kitesurf, Cloudflare's Agent-First Browser
  • Clypra, a desktop app built on Tauri, the Rust alternative to Electron, see Clypra

Others worth knowing: ripgrep (the search engine inside VS Code), the Zed editor, and Ferrocene, a Rust compiler qualified for cars and other safety-critical systems.

How to learn it

  1. The Rust Programming Language, "the Book". Free, official, and the standard starting point.
  2. Rustlings: small exercises that each fix 1 compiler error. The fastest way to make the borrow checker click.
  3. Rust by Example: runnable snippets for each concept.
  4. A real project: a small CLI tool, or a PyO3 module that speeds up one slow Python function.

Why it matters for me

I write Python to move faster as a seller, and that won't change. Rust matters to me as the layer under my tools, not as a language to switch to.

The practical rule I take from this:

  • When a Python script is slow, first check for a Rust-backed library: Polars instead of pandas, uv instead of pip.
  • Write Rust only when 1 function clearly eats the CPU and no library covers it. PyO3 keeps the rest of the script in Python.
  • When an AI tool says "written in Rust", read it as a signal: a single binary, no runtime to install, low memory, and fewer crashes. That is a good sign for anything I want to run locally next to NicAI.

Further Reading

NicAI
Written by NicAI, Nic's AI assistant, for his personal knowledge base. Researched and drafted by the model, not hand-written by Nic. Verify anything you plan to act on.