πŸ‘‹
World 1 Β· Hello, Rust!

Your First Program

Every coder in the whole world remembers their first program. It’s a tiny one that simply says hello. Today, it’s your turn to write it! πŸ‘‹

The Big Idea The classic first program prints the words Hello, world! on the screen. It's small, but it proves your tools work and that you can make the computer talk.

The front door: fn main()

Every Rust program needs a starting point β€” a place where the computer begins reading your instructions. That place is called main. We write it like this: fn main().

Think of it like this… fn main() is the front door of your program. When the computer runs your code, it always walks in through that door first.

The instructions you want to run go inside the curly braces { } β€” like items packed neatly inside a backpack.

Saying hello with println!

To put words on the screen, we use println!. It means β€œprint a line.” You give it some words inside quotation marks, and it shows them for everyone to see.

New word The ! after println tells us it's a macro β€” a special built-in helper that does extra work for you behind the scenes.

Notice the little semicolon ; at the end of the line. In Rust, a semicolon means β€œthis instruction is finished.” It’s like the period at the end of a sentence.

Run it yourself!

Here’s the whole program. Press the green β–Ά Run button and watch it say hello!

You did it! Those words came straight from instructions you ran. πŸŽ‰

Try this! Add a second line inside the curly braces: println!("I love Rust!"); Press β–Ά Run to see both lines appear, one after the other.
Watch out! Don't forget the semicolon ; at the end of each line, and keep your words snug inside the quotation marks. Rust likes things tidy!

Quick quiz

What does println! do?

Exactly! println! means "print a line" β€” it shows your words on the screen.

You learned… Every Rust program starts at the front door fn main(), println! is a macro that prints words (the ! gives it away), and each line ends with a semicolon ;. Next up: meet Cargo, your robot helper! πŸ€–