Introduction
Rust By Example - Introduction
On the first page of Rust By Example, we're greeted with this statement:
Rust is a modern systems programming language focusing on safety, speed, and concurrency.
Awesome. But what does this mean?
Over the course of completing these exercises we'll explore how Rust language prioritizes and implements these qualities.
Hello World (Chapter 1.0)
Rust By Example - Hello World!
It's tradition to create a "Hello World" program whenever you learn a new coding language. But before we do, let's take a look at the top right of our in browser coding environment.
- We can reset the code to it's original state by clicking the leftmost button
- We can copy all of the code by clicking the middle button
- We can run the code by clicking the rightmost button
If we click run we should see Hello World!
below
The println!
macro
prints our text to the console. A macro
in Rust isn't a function call although it may look like one. Instead, the contents of the macro
expand into source code. That way the body of the macro explicitly writes code which is eventually executed. This is a form of meta programming. We are writing code (println!
) that generates other code (code we put inside of println!
). We'll look at macros
more in a future post!
Lastly, we are given instructions on how to create a Rust binary in our local dev environment. Follow the instructions and you will have created an executable binary which will print out "Hello World!". An executable binary is a machine code version of any code we write. In this case, it's our "Hello World!" code!
We've completed our Hello World example!
In the next post, we'll cover the next chapter, 1.1 - Comments
Top comments (0)