Getting Started
Rust is a compiled, systems-level language, in the same broad family as Go — source code is built into a standalone executable, not interpreted line by line. But the two languages exist for genuinely different reasons, and that difference shapes everything in this course.
Why Rust Exists
Go, JavaScript, Python, Ruby, PHP, and Kotlin all rely on a garbage collector — a background process that automatically frees memory the program no longer needs. This is convenient, but it comes with real costs: runtime overhead, and pause times that are hard to predict exactly when they'll happen. Older systems languages like C and C++ skip the garbage collector entirely, giving the programmer full manual control — but with it, real risk: dangling pointers, buffer overflows, use-after-free bugs that have caused decades of security vulnerabilities.
Rust's entire reason for existing is refusing to accept that trade-off: manual-control-level performance and predictability, without the memory-safety bugs manual control usually invites — enforced not at runtime, but by the compiler itself, before the program ever runs. Chapters 3–4 cover the actual mechanism (ownership and borrowing); this chapter is just naming the goal everything else in this course serves.
Installing Rust: rustup and rustc
rustup is Rust's official installer and toolchain manager — it installs and manages Rust versions, similar in spirit to a version manager, but built and maintained by the Rust team itself as the standard, recommended way to get Rust at all.
rustc is the raw compiler underneath everything — the direct equivalent of what runs behind the scenes when Go's go build compiles a file. In practice, most day-to-day work goes through cargo instead of calling rustc directly.
cargo: Rust's Build Tool & Package Manager
This is the first real toolchain difference from Go. Go's toolchain is deliberately minimal — go run and go build are close to the whole story. cargo bundles far more into one official tool from day one: building, running, dependency management against crates.io (Rust's package registry), and testing — closer in spirit to npm and a bundler combined, except built directly into Rust's own official tooling rather than assembled from separate third-party choices.
Cargo.toml is the direct equivalent of Go's go.mod — but where a go.mod stays minimal, Cargo.toml is the central place dependencies, metadata, and build configuration all live together.
The Smallest Rust Program
fn main() is the entry point — the same role func main() plays in Go; execution always starts here. println! is Rust's equivalent of fmt.Println, but notice the ! — that marks it as a macro, not an ordinary function call. Macros are a genuinely different Rust concept from anything in Go or JavaScript (Course 3's own Macros chapter covers writing them); for now, just recognize that ! after a name means "this is a macro," and println! is the one used constantly throughout this course.
| Concept | Go | Rust |
|---|---|---|
| Compile & run in one step | go run file.go | cargo run |
| Produce a standalone binary | go build | cargo build --release |
| Project manifest | go.mod (minimal) | Cargo.toml (build config + dependencies) |
| Print a line | fmt.Println(...) | println!(...) |
| Entry point | func main() | fn main() |
;) from an expression (no semicolon, and its value can be returned). Inside main right now this mostly just means "don't forget the semicolon" — but this exact distinction becomes meaningful later when a function's last line, with no semicolon, becomes its return value. Missing or extra semicolons produce real compiler errors, not silent behavior differences.
Coding Challenges
Use cargo new to create a project called greeting, then edit src/main.rs so it prints your name and a short greeting using two separate println! calls. Run it with cargo run.
📄 View solutionWrite a program that prints "Year: 2026" and "Language: Rust" using println! with placeholders ({}) instead of concatenating strings — two separate println! calls, each using a placeholder.
📄 View solutionExplain, in your own words, why Rust's pitch ("manual-control performance without manual-control memory bugs") is a genuinely different trade-off than either a garbage-collected language or C/C++ — and name the two chapters coming up that actually deliver on that promise.
📄 View solutionChapter 1 Quick Reference
- Rust's core goal: memory safety without a garbage collector, enforced at compile time
- rustup — the official installer/toolchain manager; rustc — the raw compiler underneath
- cargo — Rust's official build tool + package manager + test runner, bundled together (unlike Go's minimal toolchain)
- Cargo.toml — the project manifest (dependencies, build config) — Rust's fuller-featured counterpart to Go's
go.mod - cargo new / cargo run / cargo build --release — create, run, and produce a standalone binary
- fn main() { } — the entry point, same role as Go's
func main() - println!(...) — note the
!: this is a macro, not an ordinary function - Semicolons distinguish statements from expressions — a distinction that becomes load-bearing later, not just style
- Next chapter: variables, basic types, immutability by default (
letvslet mut), and shadowing