Level 1 · Sprout

Hello, World! 👋

Every programmer's journey starts with the same two words. Today you'll write, compile, and run your first Rust program, and understand every single character of it.

What programming actually is

A program is a list of instructions for a computer, written in a language both humans and machines can deal with. Computers only truly understand machine code: raw numbers. So we write in a human-friendly language (Rust!) and use a compiler to translate it into machine code.

Rust's compiler is called rustc, and it's famously strict, in the best way. Think of it as a friendly proofreader who catches your mistakes before your program ever runs, instead of letting it crash later.

🧪 Two ways to follow along No installs: open the Rust Playground, copy any example (every code block here has a copy button), press Run.
The full lab: follow the setup guide; it takes about ten minutes.

Your first program

fn main() {
    println!("Hello, world!");
}

Three lines. Let's take them apart like a curious crab:

Leaving notes: comments

Anything after // is a comment: the compiler ignores it completely. Comments are notes to your future self.

fn main() {
    // I wrote this on day one. Hi, future me!
    println!("Hello, world!"); // this part actually runs
}

Meet Cargo, your project butler 🎩

You could compile files by hand with rustc, but nobody does. Rust ships with Cargo, a tool that creates projects, builds them, runs them, tests them, and fetches libraries. In your terminal:

cargo new hello_rusty   # create a project
cd hello_rusty          # step inside
cargo run               # compile + run

Cargo made this folder structure for you:

hello_rusty/
├── Cargo.toml    ← project info & dependencies (like a recipe card)
└── src/
    └── main.rs   ← your code lives here (.rs = Rust source)

After running, a target/ folder appears too; that's where compiled machine code goes. You never edit it, and you can always delete it; Cargo will rebuild.

⚡ The three commands you'll use constantly cargo run: compile and run.  cargo check: "would this compile?" in a hurry.  cargo build: compile without running.

Break it on purpose 🔨

Here's a Rusty School secret: the fastest way to learn is to break things and read what the compiler says. Delete the semicolon after println!(...) and run it. You'll get something like:

error: expected `;`, found `}`
 --> src/main.rs:2:34
  |
2 |     println!("Hello, world!")
  |                              ^ help: add `;` here

Look at that: it tells you the file, the line, the column, and the exact fix. Rust's error messages are the best teaching assistant you'll ever have. Never fear red text: read it.

⚠️ Classic first-day stumbles
  • Writing println without the !: printing is a macro, bang required.
  • Forgetting a ; at the end of an instruction.
  • Unmatched braces: every { needs its }.
  • Running cargo run outside the project folder; cd in first.
Exercise 1

Introduce yourself

Change the program so it prints your name on one line and your favorite food on the next. Two println! calls, two lines of output.

Reveal solution
fn main() {
    println!("My name is Chris.");
    println!("I could eat tacos forever.");
}
Exercise 2

Become a code-breaker

Sabotage your program three different ways (remove the !, remove a quote mark, remove a brace) and run it each time. Read each error out loud. Which one gave the most helpful hint?

Reveal thoughts

No single right answer here: the goal is to lose your fear of errors. Notice how each message points at a file, a line number, and usually a suggested fix. Compiler errors are directions, not punishments.

Exercise 3

ASCII crab

Use several println! lines to print a little crab scene. Get creative. Emoji work in Rust strings, by the way: 🦀 is fair game.

Reveal solution
fn main() {
    println!("  🦀");
    println!("~~~~~~~~");
    println!("the rusty sea");
}