Coding Hello World in Rust

Here’s the world famous hello world in Rust using nothing but rustc, Rust’s compiler. Even though this is super light-weight it is usually not what you would do because you need cargo to manage any dependency you might have on other libraries.

[Coding Hello World in Rust with Cargo]

But First …

Step by Step

Open hello.rs with your editor.

fn main() {
    println!("Hello, world!");
}

So we see a few things here:

Looks interesting enough.

Ok, let’s compile the thing.

rustc hello.rs
ls
hello hello.rs

What’s this? We have a new executable file. Let’s run it.

./hello
Hello world!

Don’t forget the ./ which tells Bash we want to run this hello right here in this here directory.

On to bigger and better things in the safest programming language ever created by humans!