~/VibeHandbook
$39

Languages

rust-lang.org

Rust

What it is

Rust is a compiled systems language focused on memory safety. Most languages run a garbage collector — an automatic memory cleaner working in the background to free up unused memory. Rust skips that and proves your memory is handled correctly while it builds your program instead. Think of a library book: only one person can hold and write in it at a time, and the system refuses to lend out a book that has already been returned and thrown away — so you can never accidentally use something that is gone. That is what Rust's ownership and borrowing model does for your data. It guarantees, before your program ever runs, that you won't hit data races (two parts of the code changing the same thing at once) or use-after-free bugs (using memory that was already cleaned up). The result is C-level speed with far fewer ways to shoot yourself in the foot.

Strengths

  • Memory safety and thread safety checked while the program is being built, with no garbage collector (the background memory cleaner most languages run) needed.
  • Performance on par with C and C++.
  • Rich type system, pattern matching, and a first-class manager (Cargo, Rust's built-in build-and-package tool).
  • Excellent compiler errors that explain what went wrong and how to fix it.

Trade-offs

  • Steep learning curve — the borrow checker (the part of Rust that enforces the one-holder-at-a-time book rules above) takes real time to get used to.
  • Slower to write and longer to compile than higher-level languages.
  • Overkill for simple scripts or quick prototypes.
  • Async Rust and lifetime-heavy generic code can get genuinely intricate.

When to reach for it

Reach for Rust when performance, reliability, and resource control all matter at once: systems software, game engines, command-line tools, WebAssembly, embedded, or performance-critical services. It's a poor fit for throwaway scripts, where the safety guarantees aren't worth the friction.

Vibe coding fit

AI assistants generate plausible Rust, but the borrow checker is the real arbiter — expect to paste compiler errors back and iterate, which works well because Rust's diagnostics are precise and the model can act on them. Direct the AI to lean on Result and ? for error handling, to prefer owned types or clear borrows over fighting lifetimes, and to suggest crates (Rust's reusable code packages, listed in Cargo.toml) explicitly. Ask for cargo test cases so you can verify safety and behavior. When the model proposes unsafe, push back and ask for a safe alternative first.

fn main() {
    let nums = vec![3, 1, 4, 1, 5, 9, 2, 6];
    let sum: i32 = nums.iter().filter(|&&n| n % 2 == 0).sum();
    println!("Sum of evens: {sum}");
}