Rust — Systems Literacy
The language of AI infrastructure
You will probably never write a full Rust application. That's fine — this module is literacy, not fluency. You need to read Rust, understand why the AI-infrastructure world is built on it, and appreciate the one idea that makes it fast AND safe: ownership.
Ownership: one owner, everyone else borrows
In Python and JS, memory cleans itself up (garbage collection) — convenient, but the program must pause to clean and can't control exactly when. In Rust, every value has exactly ONE owner. When the owner goes out of scope, the value is freed instantly — no pauses, no surprises. You can borrow a value (a reference) but the compiler enforces the rules at build time, so the class of bugs that crashes C++ programs simply cannot compile.
The compiler being strict is the feature. The moment your Rust code compiles, it's memory-safe by construction.
fn main() {
let name = String::from("underlay"); // name OWNS the string
let len = measure(&name); // &name BORROWS it — no copy
println!("{name} has {len} chars"); // owner still alive: fine
}
fn measure(s: &String) -> usize {
s.len() // reading through a borrow is always allowed
}
// fn main() { let a = String::from("x"); let b = a; println!("{a}"); }
// ^ that would NOT compile: ownership moved to b, a is gone.Real Rust: a CLI that beats Python by 10×
Here's the module's real check in miniature — count lines in a big file. Rust reads it in buffered chunks with zero GC pauses; Python's interpreter adds overhead per line. On a 1 GB file, expect the gap to be an order of magnitude:
use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader, Result};
fn main() -> Result<()> {
let path = env::args().nth(1).expect("usage: linecount <file>");
let file = File::open(&path)?; // '?' = return the error if any
let reader = BufReader::new(file); // buffered: fast sequential reads
let mut lines = 0usize;
for line in reader.lines() { // no GC, no interpreter
line?; // check each read
lines += 1;
}
println!("{lines}");
Ok(())
}Compare `time python3 -c "print(len(open('big.txt').readlines()))"` against `time ./linecount big.txt` on the same file. The Rust binary is a single static executable — that's why llama.cpp, vLLM's kernels, and most AI routers are written in this family of languages.
test yourself
01Ownership means:
02In `fn measure(s: &String)`, the `&` means:
03Why are LLM runtimes (llama.cpp, vLLM kernels) written in Rust/C++?
the real check
A Rust CLI processes a large file ≥10× faster than your Python version — and you can explain why.
0 stamps earned·streak: 0 days
Signed out: progress lives in this browser. to carry it everywhere.
vibe-coder payoff
Every serious LLM runtime is Rust or C++. Under the hood, it's everywhere.