Bonjour le monde!

Passons au programme Rust le plus simple possible, un Bonjour Monde classique programme:

fn main() {
    println!("Hello 🌍!");
}

Ce que tu vois:

  • Les fonctions sont introduites avec fn.
  • Les blocs sont délimités par des accolades comme en C et C++.
  • La fonction main est le point d’entrée du programme.
  • Rust a des macros hygiéniques, println! en est un exemple.
  • Les strings Rust sont encodées en UTF-8 et peuvent contenir n’importe quel caractère Unicode.
This slide should take about 5 minutes.

This slide tries to make the students comfortable with Rust code. They will see a ton of it over the next four days so we start small with something familiar.

Points clés:

  • Rust is very much like other languages in the C/C++/Java tradition. It is imperative and it doesn’t try to reinvent things unless absolutely necessary.

  • Rust is modern with full support for things like Unicode.

  • Rust uses macros for situations where you want to have a variable number of arguments (no function overloading).

  • Macros being ‘hygienic’ means they don’t accidentally capture identifiers from the scope they are used in. Rust macros are actually only partially hygienic.

  • Rust is multi-paradigm. For example, it has powerful object-oriented programming features, and, while it is not a functional language, it includes a range of functional concepts.