Hallo Welt!
Lasst uns in das einfachste Rust-Programm einsteigen, ein klassisches Hallo Welt Programm:
fn main() { println!("Hello đ!"); }
Du siehst:
- Funktionen beginnen mit
fn
. - Blöcke werden wie in C und C++ durch geschweifte Klammern getrennt.
- Die
main
-Funktion ist der Einstiegspunkt des Programms. - Rust hat hygienische (hygienic) Makros,
println!
ist ein Beispiel dafĂŒr. - Rust-Strings sind UTF-8-codiert und können beliebige Unicode-Zeichen enthalten.
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.
SchlĂŒsselpunkte:
-
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 ist modern und unterstĂŒtzt Dinge wie Unicode vollstĂ€ndig.
-
Rust uses macros for situations where you want to have a variable number of arguments (no function overloading).
-
Makros sind âhygienischâ, was bedeutet, dass sie nicht versehentlich Identifikatoren in ihrem Umfang (scope) in dem sie verwendet werden erfassen Rust-Makros sind eigentlich nur teilweise hygienisch.
-
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.