What is Rust?
Rust is a systems programming language focused on safety, speed, and concurrency. It achieves memory safety without a garbage collector, making it ideal for performance-critical software where reliability is paramount. First released in 2015 by Mozilla Research, Rust has been voted the most admired programming language in Stack Overflow surveys for years running.
Why Rust?
- Memory Safety: No null pointers, no dangling references, no buffer overflows — guaranteed at compile time
- Zero-Cost Abstractions: High-level ergonomics with low-level performance — you don't pay for what you don't use
- Fearless Concurrency: The type system prevents data races before your code ever runs
- Modern Tooling: Cargo (build system & package manager), rustfmt, clippy, and excellent documentation
- Growing Ecosystem: Over 140,000 crates on crates.io covering web, CLI, embedded, WASM, and more
Who Uses Rust in Production?
Rust has been adopted by some of the world's largest technology companies for critical infrastructure:
| Company | Use Case |
|---|---|
| AWS | Firecracker (microVMs), Bottlerocket OS, Lambda runtime |
| Android OS components, Chrome, Fuchsia OS | |
| Discord | Replaced Go services — reduced tail latency from 300ms to 5ms |
| Cloudflare | Pingora (HTTP proxy replacing nginx), Workers runtime |
| Microsoft | Windows kernel components, Azure IoT |
| Meta | Source control (Mononoke), Diem blockchain |
| Dropbox | File sync engine rewritten from Python |
Rust vs C++ vs Go
| Feature | Rust | C++ | Go |
|---|---|---|---|
| Memory Safety | Compile-time guaranteed | Manual (error-prone) | Garbage collected |
| Performance | Comparable to C/C++ | Maximum control | Good, but GC pauses |
| Concurrency | Compile-time safe | Manual (data races possible) | Goroutines (runtime safe) |
| Learning Curve | Steep (ownership) | Very steep | Gentle |
| Package Manager | Cargo (excellent) | CMake/Conan (fragmented) | Go modules |
Installing Rust with rustup
rustup is the official Rust toolchain installer. It manages Rust versions and associated tools like cargo, rustfmt, and clippy.
# Install rustup (macOS, Linux, WSL)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Verify installation
rustc --version # rustc 1.78.0 (or newer)
cargo --version # cargo 1.78.0
rustup --version # rustup 1.27.x
# Update Rust to latest stable
rustup update
# Install additional components
rustup component add clippy rustfmt rust-analyzer
Cargo: Rust's Build System & Package Manager
# Create a new project
cargo new hello_rust
cd hello_rust
# Project structure:
# hello_rust/
# Cargo.toml # Project manifest (dependencies, metadata)
# src/
# main.rs # Entry point
# Build and run
cargo build # Compile (debug mode)
cargo run # Compile and run
cargo build --release # Compile with optimizations
cargo check # Type-check without producing binary (fast!)
cargo test # Run tests
cargo doc --open # Generate and open documentation
Hello, World!
// src/main.rs
fn main() {
// println! is a macro (note the !)
println!("Hello, World!");
// String formatting
let name = "Rust";
let year = 2015;
println!("{name} was first released in {year}");
// Debug printing
let numbers = vec![1, 2, 3, 4, 5];
println!("Numbers: {:?}", numbers);
// Pretty debug printing
println!("Numbers: {:#?}", numbers);
}
The Rust Playground
You can try Rust code instantly in your browser at play.rust-lang.org. The playground supports stable, beta, and nightly Rust, and includes popular crates. It's perfect for experimenting and sharing code snippets.
// Try this in the Rust Playground!
fn fibonacci(n: u32) -> u64 {
match n {
0 => 0,
1 => 1,
_ => fibonacci(n - 1) + fibonacci(n - 2),
}
}
fn main() {
for i in 0..10 {
println!("fib({i}) = {}", fibonacci(i));
}
}
Key Takeaways
- ✅ Rust guarantees memory safety at compile time without a garbage collector
- ✅ Major companies (AWS, Google, Discord, Cloudflare) use Rust in production
- ✅ Cargo provides an excellent build system, package manager, and project scaffolding
- ✅ rustup manages toolchains and components like clippy and rustfmt
- ✅ The Rust Playground lets you experiment in the browser instantly