Rust Foundations · 7 min · free lesson

What Rust Is

Rust is a compiled, statically typed language without a garbage collector. The compiler checks types, ownership and borrowing before your program runs, then produces a native program.

Core idea

Rust is a compiled, statically typed language without a garbage collector: rustc checks types, ownership and borrowing before the program runs, then produces a native executable.

Coming from C? What Rust Is, from C covers this side by side. · Coming from Node.js? Node.js runtime vs compiled Rust covers this side by side.

Start with the idea

Rust is a general-purpose programming language for software where speed, predictable memory use and correctness all matter: command-line tools, web servers, embedded devices, WebAssembly modules, and parts of operating systems and browsers. Its first stable version, Rust 1.0, was released in May 2015. A new stable compiler is published every six weeks, and editions such as Rust 2024 let the language evolve without breaking code written for an earlier edition.

Read the code

fn area(width: u32, height: u32) -> u32 {
    width * height
}

fn main() {
    let room = area(4, 3);
    println!("area = {room}");
}

Before anything runs, rustc checks that area gets two u32 values and returns one; the built program then prints area = 12.

Practice starter

fn area(width: u32, height: u32) -> u32 {
    width * height
}

fn main() {
    let room = area(4, "3");
    println!("area = {room}");
}

Practise this code in Playground ↗

Overview: main.rs passes rustc's type, ownership and borrowing checks and LLVM to become a program that runs on its own, while a type error such as E0308 stops the build; who frees memory in C, in garbage-collected languages and in Rust; and when a type mistake shows up.
Rust checks a program while building it and then runs native code; memory is released by owners, not by a garbage collector.

Work through it

Rust is compiled ahead of time. The compiler, rustc, reads your source, checks it, and translates it through LLVM into machine code for a target: an iPhone, a Linux server, or wasm32-wasip1, the WebAssembly target Crabrix uses to run your programs on the device. The result runs on its own; no interpreter or virtual machine has to be installed. Languages that run source directly, such as Python, or compile it while running, such as JavaScript in V8, discover many mistakes, like calling a method that does not exist, only when the faulty line executes.

Rust is statically typed. Every value has a type the compiler knows, such as u32, String or bool. The compiler often infers types, so you do not write them everywhere, but it never guesses them while the program runs. In the example, area promises to take two u32 values and return one. Passing the text "3" instead is error E0308, mismatched types, and no program is built, so a program with that mistake never exists.

Rust has no garbage collector, and you do not call free either. Each value has one owner, and the value is dropped, its memory released, exactly when that owner goes out of scope. The compiler enforces these ownership and borrowing rules, which is how safe Rust rules out use after free, double frees and data races without a collector running in the background. The rules are introduced gradually in this course and explained in depth in Ownership Mastery.

Two tools do the work. rustc compiles a crate; Cargo builds whole projects, runs tests and downloads libraries, called crates, from crates.io. In Crabrix the compiler is part of the app, so Run performs both steps on your device: compile, and only if that succeeds, execute.

Try it

Change the call to area(4, "3") and build. Note the error code and the line rustc points to, then restore the number and run it again.

What success looks like: You can explain what happens before a Rust program runs: rustc checks types and ownership, and only a program that passes those checks is built and executed.

Check your understanding

area takes two u32 values. What happens when you build area(4, "3")?

Reveal the answer
  1. It builds, then crashes at run time when area multiplies a number by text
  2. rustc reports E0308 mismatched types, and no new program is built
  3. Rust converts "3" to the number 3 automatically
  4. It builds with a warning and passes 0 for the text

Rust is statically typed and compiled ahead of time: the mismatch is found while building, so no program containing the mistake is produced.

One more experiment

Call area(4, -3) and predict the diagnostic before you build. Then explain why it appears before anything is printed.

Learn this lesson with AI

Paste this into Claude, Codex, Cursor or another agent connected to Crabrix Academy. It contains only this lesson’s public details.

I'm learning Rust with Crabrix Academy. Teach me this lesson with the Crabrix Academy tools.
Lesson: What Rust Is (courseId "basics", lessonId "what-is-rust")
Link: https://crabrix.com/learn/basics/what-is-rust/
Goal: Rust is a compiled, statically typed language without a garbage collector: rustc checks types, ownership and borrowing before the program runs, then produces a native executable.
Practice: open the starter in the Crabrix Playground (https://crabrix.com/playground/?lesson=basics/what-is-rust) and I will write the code there.
Explain it step by step for my level, let me write the code myself, give hints before any solution, and do not mark anything as passed: only Crabrix checks do that.

In Claude Code, Codex or Cursor, paste it into a chat with Crabrix Academy connected. On a phone, the Claude and ChatGPT apps open the same links.