Module 1Getting StartedLesson 1 of 1018 min
Why Rust for Finance?
Memory safety, speed, and reliability — why quants and trading systems pick Rust over Python/C++/Java.
The problem quant code faces
Quantitative systems must be fast (price thousands of options, process market data) and correct (a use-after-free in a risk engine is a career-limiting bug). Historically teams chose:
| Language | Speed | Safety | Pain points |
|---|---|---|---|
| Python | Slow (unless NumPy) | GC, easy | Latency, GIL, production hardening |
| C++ | Very fast | Manual memory | Subtle UB, long build/debug cycles |
| Java/C# | Good | GC | GC pauses, less control over layout |
| Rust | Very fast | Compile-time | Steeper learning curve |
What Rust gives you
- No garbage collector — predictable latency for pricing and order handling
- No data races (in safe Rust) — shared state is checked at compile time
- Zero-cost abstractions — iterators and generics often compile to the same code as hand-written loops
- A strict compiler — many bugs never reach production
Mental model (three ideas)
- Ownership — every value has one owner; when the owner goes away, the value is freed
- Borrowing — you can lend data temporarily without giving it away
- Types as contracts — encode “this order must have a side” or “this parse might fail” in the type system
Hello, quant world
Every executable starts at fn main(). println! is a macro (the ! matters).
Walkthrough example
rust
fn main() {
let desk = "Equity Derivatives";
println!("Desk: {}", desk);
println!("Status: {}", "READY");
}Output
Desk: Equity Derivatives
Status: READYThe {} is a placeholder filled by later arguments — like formatted logging you’ll use for fills and risk.
Common beginner mistakes
- Forgetting
!onprintln→ “expected function, found macro” style confusion - Using single quotes for strings (
'hello') — strings need"double quotes";'A'is a single character - Expecting Python-style indentation to define blocks — Rust uses
{ }
Try it
Run the starter, then personalize the output.
Challenge
Print five lines: desk name, trader, strategy, notional, and market status (OPEN/CLOSED).
Tips
- println! requires the ! — it is a macro, not a function
- Each statement ends with a semicolon
- You can call println! as many times as you want
Try it live
Why Rust for Finance?Rust 2021
Loading editor…
Output
Press Run to compile and execute.