What is Rust?
- Rust course
- Beginner
- Lesson 1/115
- 4 min
Learn that Rust is a safe, fast and concurrent systems language.
What is Rust?
Rust is a compiled systems programming language that aims to be as fast as C/C++ while being safe against memory bugs. It has no garbage collector; memory is managed at compile time through ownership rules.
fn main() {
let mesaj = "Merhaba Rust";
println!("{}", mesaj);
}Parts of Firefox, Linux kernel drivers, and the infrastructure of Discord and Cloudflare are written in Rust.
Why Rust?
Rust makes three promises: safety (null pointers, data races and use-after-free bugs are caught at compile time), speed (zero-cost abstractions, no runtime overhead) and concurrency (the compiler rejects unsafe access to shared data). The cost: the compiler is strict and the learning curve is steeper than other languages.
Practice First line
Inside main, declare let dil = "Rust"; and print it with println!("{} öğreniyorum", dil);.
Starter code
fn main() {
// buraya yaz
}Sample solution
fn main() {
let dil = "Rust";
println!("{} öğreniyorum", dil);
}Expected output
Rust öğreniyorum
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 How does Rust manage memory?
- Through an interpreter
- With ownership rules, at compile time Correct answer
- With a garbage collector
- The programmer frees every allocation by hand
Explanation: The compiler tracks that every value has one owner and frees memory automatically when the owner goes out of scope.
2 Entry point
____ main() {
println!("Merhaba");
}
fn main() {
println!("Merhaba");
}
Explanation: In Rust functions are defined with fn; the program starts at main.
3 Promise and meaning
| Term | Meaning |
|---|---|
Safety |
Memory bugs are caught at compile time |
Speed |
No runtime overhead |
Concurrency |
Data races are rejected |
Sahiplik |
Instead of a garbage collector |