← Back to Rust Course | Chapter 1: Setup & Basics | Lesson 1 of 7

Introduction to Rust

Rust is a programming language that helps computers run programs very fast while stopping you from making mistakes that crash them.

What is Rust?

Rust is an open-source, statically typed, compiled systems programming language created by Mozilla and first released in 2010. It is designed to give you the speed and control of languages like C and C++, while using a unique ownership system to guarantee memory safety at compile time instead of at runtime.

Example: What is Rust?

markup
fn main() {
    println!("Rust is a systems programming language");
    println!("It is fast, safe, and compiled");
}

Why Rust Was Created

Rust was designed to solve memory-safety bugs (like null pointer dereferences and data races) that plague C and C++ programs, without paying the performance cost of a garbage collector. Its ownership model checks memory usage rules at compile time, so an entire class of bugs simply cannot exist in a program that compiles successfully.

Note: "Fearless concurrency" is a phrase from the Rust community meaning the compiler prevents data races before you even run the code.

Example: Why Rust Was Created

markup
fn main() {
    let goals = ["memory safety", "zero-cost abstractions", "fearless concurrency"];
    for g in goals.iter() {
        println!("Design goal: {}", g);
    }
}

Where Rust Is Used

Rust is used for command-line tools, web backends, operating system components, browser engines, and game engines because of its speed and safety guarantees. Companies like Mozilla, Microsoft, Amazon, and Discord use Rust for performance-critical services where crashes or memory bugs are unacceptable.

Example: Where Rust Is Used

markup
fn main() {
    let used_for = [("Firefox", "browser engine parts"), ("AWS", "infrastructure tools"), ("Discord", "backend services")];
    for (company, purpose) in used_for.iter() {
        println!("{}: {}", company, purpose);
    }
}

Compiled, Not Interpreted

Unlike Python or JavaScript, Rust source code is compiled ahead of time by rustc into a native executable before it ever runs. This means the compiler checks types, ownership, and many logic errors before the program starts, and the resulting binary runs without needing Rust installed on the machine that executes it.

Note: You can see the compiled binary yourself: rustc main.rs produces an executable file you can run directly.

Example: Compiled, Not Interpreted

markup
fn main() {
    println!("This program was compiled to machine code before running");
    println!("No interpreter is needed at runtime");
}
Common Mistakes
  1. Assuming Rust is only for systems programming experts and skipping it because it seems too hard for beginners.
  2. Confusing Rust's compiler errors with failures -- the compiler is actually catching bugs before the program ever runs.
  3. Thinking Rust needs a garbage collector like Java or Python; it manages memory through ownership rules instead.
Chapter Summary
  • Rust is a systems programming language focused on speed, memory safety, and safe concurrency.
  • It achieves memory safety without a garbage collector through its ownership and borrowing system.
  • Rust compiles to fast native binaries and is used for CLI tools, web backends, game engines, and embedded systems.
  • Its strict compiler catches many bugs at compile time instead of at runtime.
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.