This section is also available in the form of film.

1.1 Get-go

Before we can do anything using the Rust programming language, we’re going to need to install it. Without Rust on our computers—how on Earth are we expecting to make use of it?

Installation

The Rust installation is supported by most major operating systems, and have been sorted into tiers by Rust’s development team. Builds for the most common operating systems such as newer versions of Unix and Windows are labeled as guaranteed to work, whilst other systems that in theory should support Rust may fail to successfully build.

Unix

For those of you on a Unix-based operating system such as Mac or Linux, installing Rust is as simple as opening your terminal window and entering a single command—where the $ symbolizes input into the terminal:

$ curl https://sh.rustup.rs -sSf | sh

Using this command—with these specific parameters—will download the installation of the Rust programming language from the page where it’s hosted, as well as run and install it. Upon successfully having installed Rust, you’ll be notified:

Rust is installed now. Great!

Once Rust has been installed on your system, it’s about time you try it out!

Windows

For human beings on a Windows-based operating system, things may feel slightly more tedious to install—but is by no means any more difficult. Follow this link to download the latest version of Rust’s installer. Open the downloaded file and an installation guide for Rust will pop up. Follow the installation guide through and you should be good to go!

Testing

In order to make sure Rust has been installed correctly, we can run Rust’s compiler command inside the terminal or command prompt, depending on what system you’re on, with the --version flag to check what version it’s currently in:

$ rustc --version

The command rustc stands for ‘Rust compile’ and is the executable Rust compiler. This command looks the same on both Windows and Unix. With a little help from rustc’s --version flag, we output the current version of Rust into the console:

rustc 1.12.1 (d4f39402a 2016-10-19)

This version may look different depending on when in time you decide to download and install the Rust programming langauge. If the command worked correctly, we can be certain that the compiler for Rust successfully has been installed.

Uninstallation

Whether you feel extremely unaccomplished or just show a lack of interest towards Rust, there are procedures you can follow in order to rid it from you computer.

Unix

Inside Unix we can uninstall Rust using a single command inside our terminal:

$ rustup self uninstall

This will talk to your installed version of Rust and immediately uninstall it from your computer.

Windows

As for Windows-based systems, you will have to manually enter into the list of programs contained by your computer’s control panel under the section for uninstalling programs. In there, you’ll have to search or scroll through the menu, ultimately searching for a program named Rust. Once found, ’tis as simple as pressing the uninstall button.

Get’n to cod’n

Since we can’t be entirely certain our compiler is going to correctly compile code for us at this very moment, we are also going to need to test that feature out. Regardless of your knowledge regarding other programming langauges, it’s always beneficial to write a test program whenever you start developing under a new langauge.

Text editor

Before we can get started writing code, you’re going to need a text editor for programming. Should the case be you don’t have one that suits programming, might I recommend one of the following:

  • Notepad++—has been around for ages—yet manages to keep you happy. Featuring a huge set of plugins, Notepad++ is a great text editor for the general user. Did I tell you it’s free?
  • Sumlime Text 3—being the newest in the serie—it’s a great text editor for programming and, like Notepad++, features a gigantic set of plugins. Whilst Sublime Text 3 technically costs money, there’s no time limit as to how long you can evaluate it for free. It’s required to purchase it should you be planning on using it extensively.

Both these editors are on their way out of life, as new edtors are developed pretty much all the time. These ones work; that’s is what’s good about them. They never let you down.

Hello, world!

It’s about time we write a fully functional Rust program. Enter the following code inside your text editor of choice:

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

Save this piece of code as hello_world.rs and remember the location you save it at. As to how this code works is covered in the following section Behind the scenes, but first we shall compile and run this program!

Console navigation

Before you can compile your file, you’re going to need to know how to navigate around your console application—terminal or command prompt. Should you have no clue as to how navigation in your terminal or command prompt works, a tiny guide for each operating system is available just below. If you’re looking for an in-depth tutorial on the overall usage of your console, I’d suggest you head to your favorite search engine and enter in a rather clever search query explaining your troubles.

Unix

Inside the terminal on Unix-based systems, the following commands can be used for navigation:

  • ls → Lists all directories inside the current folder.
  • cd → Enters a directory listed by ls.. symbolizes the previous folder you were in.

Windows

On Windows inside the command prompt, the following commands may be used for navigation:

  • dir → Lists all directories inside current folder.
  • cd → Enters a directory listed by dir.. symbolizes the previous folder you were in.

Compiling and running

Locate the folder where you saved your hello_world.rs file by using your console. From there, enter this command:

$ rustc hello_world.rs

The Rust compiler will compile specified file using the rustc command. Depending on whether you’re on Windows or Unix, the compiled version of your program will either have an extension of type .exe or lack an extension completely respectively—either way, this file is an executable and may be run. The executable file generated by the compiler will have the same name as the one given to the compiler, with the slight difference of being executable, compiled into code the computer can understand.

Our new file requires running! Still located inside the same folder—choose a method of running depending on your operating system.

Unix

$ ./hello_world
Hello, world!

By writing out the same folder using ./ followed by the file’s name you run that executable file. “Hello, world!” is printed out into the console as a result of running our program. The single dot symbolizes the same folder

Windows

$ hello_world
Hello, world!

Simply entering the name of a .exe file inside the command prompt on Windows will automatically run it. “Hello, world!” is printed out into the console as a result of running your program.

Moreover

Knowing how to install the programming languages you’re working with will prove helpful whenever your computer may decide to die on you. It’s always good to also have the knowledge of writing a test program, as this will show you a simplified version of what that programming language in particular is going to be all about. In the following section Behind the scenes, we’ll touch the surface of how the code from this section works.