Rust Introduction
Rust is a modern systems programming language focused on three goals: speed, memory safety and fearless concurrency. It gives you the low-level control of C and C++, but its compiler checks your code so that whole families of bugs — dangling pointers, data races, use-after-free — simply cannot compile.
What is Rust used for?
- Command-line tools (for example
ripgrepandbat) - Web servers and back-end services
- Operating systems, embedded devices and firmware
- WebAssembly modules that run in the browser
- Game engines and performance-critical libraries
Why learn Rust?
| Feature | What it means for you |
|---|---|
| No garbage collector | Predictable performance and small binaries |
| Ownership system | Memory safety is checked at compile time |
| Great tooling | cargo builds, tests, documents and publishes your code |
| Helpful compiler | Error messages explain the problem and suggest a fix |
Your first Rust program
Every Rust program starts running in a function called main. Press ▶ Run to compile and run it, then change the text and run it again.
fn main() {
println!("Hello, World!");
}Hello, World!
println! prints a line of text. The ! means it is a macro, not a normal function — you will learn more about that in the Output chapter.
Tip: In every playground on ExcelTAD you can edit the code and press Ctrl+Enter to run it.
Printing more than one line
fn main() {
println!("Rust is fast.");
println!("Rust is safe.");
println!("Rust is fun!");
}Rust is fast.
Rust is safe.
Rust is fun!
Test yourself
Which function does every Rust program start from?
- start()
- main()
- run()
- init()
What does the ! in println! tell you?
- The call is unsafe
- It is a macro
- It prints an error
- It returns a boolean