Getting started
Install the toolchain, set up your editor, and run your first program.
Rust is a systems language with the safety guarantees of a memory-managed one. The compiler is unusually strict, and that strictness is the point: most classes of bug never compile. If you orchestrate AI agents writing code for you, that strictness becomes a verification tool. Either the code compiles and passes the lints, or you know exactly where to look.
This chapter installs the toolchain, sets up an editor that can read Rust, and adds two non-default tools every orchestrator should have on day one.
Why Rust, and who actually uses it
A short, honest list of where Rust is the obvious choice today:
- Query engines. Polars (DataFrame), DataFusion (SQL/exec), and Sail (Spark-compatible distributed) are all Rust. Sail is built on DataFusion 53. The data engineering community moved here for predictable performance without GC pauses.
- AI inference at the edge. Candle, Burn, and the ONNX runtime bindings (
ort) cover a lot of inference workloads where you want a small, statically linked binary instead of a Python process. - Agent infrastructure. Vector stores (Qdrant), MCP servers, embedding pipelines, runtime sandboxes. The pieces that need to be small, fast, and not crash.
- Operating systems and embedded. Linux now accepts Rust drivers. Microsoft is rewriting parts of Windows. Embedded Rust runs on microcontrollers with no allocator.
- Web infrastructure. Tokio plus Axum or Actix powers a lot of high-throughput services where Go's GC or Python's GIL was the bottleneck.
What ties these together: they care about latency tails, binary size, and the ability to ship without a runtime. Rust gives you that without the footguns of C++.
Install Rust
The official installer is rustup. It manages compiler versions, toolchains, and components. On macOS or Linux:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shOn Windows, download rustup-init.exe from rustup.rs. Either way, restart your shell, then verify:
rustc --version
cargo --versionrustc is the compiler. cargo is everything else: the build system, package manager, test runner, doc generator, formatter, linter shim. For most projects you only ever invoke cargo.
Hello, world
Create a new project. Cargo lays out the directory for you.
cargo new hello
cd hello
cargo runYou should see Hello, world!. The generated src/main.rs is:
fn main() {
println!("Hello, world!");
}fn main() is the program entry point. println! is a macro (note the !), not a function. Macros expand to code at compile time; they can do things normal functions cannot, like accepting a variable number of typed arguments.
Cargo also generated Cargo.toml, which is the project manifest:
[package]
name = "hello"
version = "0.1.0"
edition = "2021"
[dependencies]edition is Rust's mechanism for opt-in language changes that would otherwise break older code. Sail uses edition = "2021" across its workspace. The 2024 edition is out but not universally adopted yet; stick with 2021 unless a project tells you otherwise.
Editor setup
Install rust-analyzer in your editor. It is the language server. In VS Code it is one extension. In Neovim, Helix, and Zed it is built in or one-config-line away. Once it is running, you get inline type hints, jump-to-definition, and the compiler's diagnostics live as you type.
Do not skip this. Reading Rust without inline types is much harder than it needs to be. Agents write code that is correct but unfamiliar to you; rust-analyzer is what makes it readable.
The orchestrator's setup
Two extra tools matter from day one. Install both.
cargo install cargo-nextest --locked
cargo install cargo-watch --lockednextest is a faster, friendlier test runner. The default cargo test is fine for small projects. Nextest gives you parallel execution with proper isolation, structured output, and retry policies. When an agent claims "tests pass," cargo nextest run is the gate you actually want.
cargo-watch reruns commands on file change. The loop most orchestrators want is:
cargo watch -x check -x test -x clippyThat runs the type checker, the test suite, and the linter on every save. If the agent submits work, you let it run for a few seconds and see exactly which gate failed, if any.
A note on clippy. It is Rust's linter and it ships with rustup. You do not install it separately. Many production codebases treat clippy warnings as build errors. Sail does.
The four cargo verbs
You will use these constantly. Learn them now, in this order:
| Command | What it does |
|---|---|
cargo check | Type-check the code without producing a binary. Fastest feedback loop. |
cargo build | Compile a debug binary. Slow first time, fast afterward. Add --release for optimized. |
cargo test | Run unit and integration tests. Use cargo nextest run instead once installed. |
cargo run | Build and run the binary. Accepts arguments after --: cargo run -- arg1 arg2. |
Add cargo fmt (autoformat) and cargo clippy (lint) to the rotation as soon as you have a working program.
What you have now
A working Rust toolchain. An editor that understands the language. Two tools (nextest, cargo-watch) that turn agent output into a tight loop. That is enough to start writing real programs.
The next chapter writes one: a guessing game, end to end. You will use the standard library for input, pull in your first external crate for randomness, and meet match, loop, and the Ordering enum. After that, the deeper concepts (ownership, lifetimes, traits) sit on a much more concrete foundation.