Getting Started with Rust: Installing and Running a Program
NicolasBrondinBernard
Learn how to install Rust and compile your first program. A clear introduction to help you get started with this modern, fast, and secure language, designed for demanding developers.

Article published on 10/06/2025, last updated on 10/08/2026
Rust is a low-level, fast, and safe programming language that is increasingly establishing itself by replacing C and C++ on many large-scale projects, such as the Linux Kernel.
It is particularly appreciated for its memory management system without a garbage collector, its performance and its robustness.
Installing Rust
The recommended way to install Rust is to use the rustup tool, which installs both:
- the Rust compiler (
rustc) - the package and project manager
cargo
On Linux and macOS
Open a terminal and run:
curl https://sh.rustup.rs -sSf | sh
This script downloads the installer, explains what it will do, then installs everything needed. If everything goes well, you should see this message:
Rust is installed now. Great!
Then, remember to restart your terminal or run:
source $HOME/.cargo/env
On Windows
Download and run the file rustup-init.exe. A console will open and guide you through the installation. Once finished, you should see the same success message.
⚠️ Make sure the installation properly added Rust to your PATH.
You can test it with:
rustc --version
cargo --version
Writing a basic program
Let's write a first program that displays a personalized "Hello World!".
- Create a folder for your project:
mkdir hello-rust
cd hello-rust
- Create a
main.rsfile:
fn main() {
let name = "Alice";
println!("Bonjour, {} !", name);
}
This program:
- declares a variable
name - displays a message with
println!, Rust's display macro
The
{}is a placeholder that will be replaced by the value of thenamevariable. You can add several if needed, likeprintln!("{} a {} ans", nom, age);.
Compiling and running the program
Manually
You can compile the file with rustc:
rustc main.rs
This generates an executable (main on Linux/macOS, main.exe on Windows) that you can run:
./main
or
main.exe
With Cargo (recommended)
Cargo is Rust's official project management tool.
It handles dependencies, compilation, execution, etc.
To create a new project:
cargo new hello-rust
cd hello-rust
This creates a complete project structure with:
- a
Cargo.tomlfile (configuration) - a
src/folder with amain.rsfile
You can then run your program with:
cargo run
cargo runcompiles (if needed) and runs your program automatically.
Complete courses, exercises and certificates to really learn programming!
4.8 average rating
No comments yet