# Rust Compiler Toolchain

There are different ways to install Rust toolchain in your system. You can compile it from scratch or use your OS package manager. But the easiest way to install Rust toolchain is by using rustup, which is an installer for Rust. You can visit [**https://rustup.rs**](https://rustup.rs) and follow the instructions to install it.

## **Installing rustup on the Linux OS or macOS**

If you are using Debian 10 Linux distribution, the following instructions are applicable. However, if you are already using a different Linux distribution, we will assume that you are familiar with the Linux operating system and can adjust these instructions to suit your Linux distribution.

```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

It will then show a prompt, which you can customize; for now, we're just going to use the default setup:

```bash
...
1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>
```

Type `1` to use the default installation.

After that, reload your terminal or type this in the current terminal:

```bash
source $HOME/.cargo/env
```

You can confirm whether the installation was successful or not by typing `rustup` in the Terminal and you should see the usage instruction for rustup.

Now, let's install the stable Rust toolchain. Type the following in the terminal:

```bash
rustup toolchain install stable
```

After the toolchain has been installed into your OS, let's confirm whether we can run the Rust compiler. Type `rustc` in the terminal and you should see the instructions on how to use it.

## **Updating the toolchain, rustup, and components**

The Rust toolchain has a regular release schedule of around every three months (six weeks plus six weeks), but sometimes there's an emergency release for a major bug fix or a fix for a security problem. As a result, you sometimes need to update your toolchain.

Updating is very easy. This command will also update the components installed in the toolchain:

```bash
rustup update
```

Besides the toolchain, `rustup` itself might also be updated. You can update it by typing the following:

```bash
rustup self update
```

Now that we have the Rust compiler toolchain installed in our system, let's write our first Rust program!

# **Writing Hello World!**

We are going to write a very basic program, *Hello World!*. After we successfully compile that, we are going to write a more complex program to see the basic capabilities of the Rust language. Let's do it by following these instructions:

1. Let's create a new folder, for example, `try-rust`.
    
2. Create a new file inside the folder and give it the name [`main.rs`](http://main.rs).
    
3. Let's write our first code in Rust:
    
    ```rust
    fn main() { 
        println!("Hello World!");
    }
    ```
    
4. After that, save your file, and in the same folder, open your terminal, and compile the code using the `rustc` command:
    
    ```bash
    rustc main.rs
    ```
    
5. You can see there's a file inside the folder called `main`; run that file from your terminal:
    
    ```bash
    ./main
    ```
    
6. Congratulations! You just wrote your first `Hello World` program in the Rust language.
    

# Closing

Rust is a promising and powerful programming language that offers excellent memory safety and performance. With the resources and tips outlined in this guide, you can get started with Rust programming and take advantage of its unique features. Whether you are a seasoned developer or a beginner, Rust provides an exciting opportunity to create efficient, reliable, and safe software. Keep exploring, learning, and experimenting with Rust to unlock its full potential!

Keep an eye out for future posts where I'll delve into even more interesting topics. In the meantime, I hope this information has been helpful and I look forward to your continued engagement. Thanks again!
