The VikiD Truth

Knowledge base / Computing

Algorithms | Apple | AssemblyLanguage | BASH | Bash Cookbook | C-Programmming | CommonLisp | Computer Security | CuisSmalltalk | Databases | Emacs | Exploitation | Firewalls | Fortran | Functional Programming | Git | GNUSmalltalk | Haskell | Javascript | Julia | Linux | Machine Learning | Metasploit |Machine Learning | Networking | Operating Systems | Open Data Science | Odin | Picolisp | Pharo Smalltalk | Purescript | Python | Racket | Rust| Scheme | Social Engineering | Unity | vim | V | Web Development | Windows |Zig

Rust

Here is the truth Rust is built on: most bugs that crash systems and open security holes are memory bugs, and a compiler can stop nearly all of them – if you’re willing to talk to it about ownership. Rust is that conversation.

What it is, in plain words

Rust is a general-purpose language sponsored by the Rust Foundation, first stable in 2015, aimed at the same jobs as C and C++: operating systems, browsers, engines, embedded, CLI tools and performance-sensitive services. Its headline idea is memory safety without a garbage collector, enforced at compile time by the ownership and borrowing rules:

Get those wrong and the program doesn’t compile. Get them right and you don’t get use-after-free, double-free or data races.

Other pillars: algebraic types (enum with data, pattern matching), traits (like type classes / interfaces), a fearless concurrency story, and a first-class toolchain – rustc, Cargo (build + packages), rustfmt, Clippy.

Why it matters

The Linux kernel accepts Rust now. Android, Windows, Firefox, Cloudflare, AWS and Discord use it in production. The NSA and consumer-protection agencies have publicly urged moving away from C/C++ for new code. If you care about systems programming in 2026, Rust is no longer optional knowledge – even if you keep writing C for pleasure or PicoLisp for joy.

An everyday analogy: a library with a strict librarian

In C, anyone can photocopy a book, scribble in it, or shelve two copies of the same rare manuscript. In Rust the librarian enforces rules: one person owns the book; anyone may read it over their shoulder (&T); only one person at a time may take it to the desk and annotate (&mut T); and when the owner leaves the building, the book goes back on the shelf (or into the bin). Annoying when you’re in a hurry. Wonderful when nothing gets lost.

flowchart LR
  O[Owner: String] -->|move| N[New owner]
  O -.->|borrow &| R1[Reader]
  O -.->|borrow &| R2[Reader]
  O -.->|borrow &mut exclusive| W[Writer]

A hands-on example

Install with rustup (the standard way – distro packages lag and split the toolchain oddly):

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
rustc --version
cargo new hello && cd hello

src/main.rs:

use std::collections::HashMap;

#[derive(Debug)]
struct Machine {
    name: String,
    uptime_days: u32,
}

fn greet(m: &Machine) -> String {                 // shared borrow
    format!("{} has been up {} days", m.name, m.uptime_days)
}

fn bump(m: &mut Machine) { m.uptime_days += 1; }  // mutable borrow

fn main() {
    let mut box_ = Machine {                       // box is a reserved word
        name: String::from("vikix"),
        uptime_days: 12,
    };
    println!("{}", greet(&box_));
    bump(&mut box_);

    // Ownership: this *moves* the String out
    let name = box_.name;
    // println!("{}", box_.name);   // error[E0382]: borrow of moved value
    println!("{name}");

    // Pattern matching and Result
    let nums = vec![3, 1, 4, 1, 5];
    let total: i32 = nums.iter().map(|n| n * n).sum();
    println!("sum of squares = {total}");

    let mut counts: HashMap<&str, u32> = HashMap::new();
    for w in ["void", "lisp", "void"] {
        *counts.entry(w).or_insert(0) += 1;
    }
    println!("{counts:?}");

    // Errors are values
    match std::fs::read_to_string("/etc/os-release") {
        Ok(s) => println!("first line: {}", s.lines().next().unwrap_or("?")),
        Err(e) => eprintln!("nope: {e}"),
    }
}
cargo run
cargo clippy          # the linter you should always keep on
cargo test
cargo build --release # optimised binary in target/release/

The parts you’ll keep learning

Common misconceptions

Connections

Scalar Types

Signed integers:   i8, i16, i32, i64, i128 and isize (pointer size)
Unsigned integers: u8, u16, u32, u64, u128 and usize (pointer size)
Floating point:    f32, f64
char               Unicode scalar values like 'a', 'α' and '∞' (4 bytes each)
bool               either true or false

The unit type (), whose only possible value is an empty tuple: () Compound Types

Arrays like [1, 2, 3]
Tuples like (1, true)

Last edited · 3 revisions

Tags: #Computing