Skip to main content

Hello, world in Rust

Every Rust program starts at `fn main()`. There is no top-level script body the way there is in Python or JavaScript: the compiler needs one clearly named entry point to hand to the operating system once the machine code is built.

`println!` is a macro, not a function — that is what the exclamation mark means. The macro is expanded at compile time and it checks your format string against the arguments you passed. If the placeholders do not line up, the program never builds, so a whole class of formatting bugs simply cannot reach production.

Run this and change the greeting. The result on the right is genuine output from a real rustc build, not a simulation.

Run it and change it

The editor below is live: edit anything and the real compiler output updates by itself.

Your Rust