Getting Started with Rust

Rust is a systems programming language that is fast, memory-safe without a garbage collector, and increasingly popular for writing web servers, CLI tools, and embedded software.

Why Rust?

A few things stand out compared to other languages:

  1. Memory safety at compile time — the borrow checker eliminates entire categories of bugs before you even run the code
  2. Zero-cost abstractions — high-level ergonomics that compile down to efficient machine code
  3. Fearless concurrency — the type system prevents data races

The Ownership Model

The core concept that makes Rust unique is ownership. Every value has a single owner, and when the owner goes out of scope, the value is dropped — no garbage collector needed.

fn main() {
    let s = String::from("hello");
    let t = s; // ownership moves to t
    // println!("{}", s); // compile error: s was moved
    println!("{}", t);   // this works fine
}

Once you internalize ownership, a lot of other Rust concepts fall into place naturally.

Getting Started

Install Rust via rustup, which also installs cargo, the build tool and package manager:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Then create a new project:

cargo new my-project
cd my-project
cargo run

That's all it takes to go from zero to a running Rust program.

← Back