2022-12-21 17:36:30 +02:00
# Hello World!
Let us jump into the simplest possible Rust program, a classic Hello World
program:
2023-04-27 23:45:41 +02:00
```rust,editable
2022-12-21 17:36:30 +02:00
fn main() {
println!("Hello 🌍!");
}
```
What you see:
* Functions are introduced with `fn` .
* Blocks are delimited by curly braces like in C and C++.
* The `main` function is the entry point of the program.
2022-12-21 22:26:23 +02:00
* Rust has hygienic macros, `println!` is an example of this.
2022-12-28 10:32:28 +02:00
* Rust strings are UTF-8 encoded and can contain any Unicode character.
2022-12-27 17:52:41 +02:00
< details >
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.
Key points:
* Rust is very much like other languages in the C/C++/Java tradition. It is
2023-07-18 01:13:06 +02:00
imperative and it doesn't try to reinvent things unless
2022-12-27 17:52:41 +02:00
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 ](basic-syntax/functions-interlude.md )).
2023-03-03 14:19:52 +02:00
* Macros being 'hygienic' means they don't accidentally capture identifiers from
the scope they are used in. Rust macros are actually only
2023-05-24 10:15:08 +02:00
[partially hygienic ](https://veykril.github.io/tlborm/decl-macros/minutiae/hygiene.html ).
2023-03-03 14:19:52 +02:00
2023-07-18 01:13:06 +02:00
* Rust is multi-paradigm. For example, it has powerful [object-oriented programming features ](https://doc.rust-lang.org/book/ch17-00-oop.html ),
and, while it is not a functional language, it includes a range of [functional concepts ](https://doc.rust-lang.org/book/ch13-00-functional-features.html ).
2022-12-27 17:52:41 +02:00
< / details >