Getting started with Rust

Getting started with Rust

ยท

2 min read

What is Rust ?

"Rust is a modern systems programming language focusing on safety, speed, and concurrency". Which is why it's becoming more popular in the Blockchain world.

This article will guide you through how to install rust, and how to run your first Hello World program in Rust.

How to install rust

We'll be installing rust through rustup, which is a command line tool for managing Rust versions.

For Linux or MacOS

Open your terminal and run the following command:

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

For Windows

Download and install rust from the rust installation page

You can also install a Linux Virtual environment and run the same command above.(recommended)

NB: If you get a linker 'cc error: run apt install build-essential and try again.

Now that you've Rust installed, Let's run our first Rust program.

Enter the following command in your terminal:

cargo new hello-rust

This will generates a "Hello, world!" project for you in the directory, "hello-rust".

IMG_20220126_092816.jpg

Now move into this directory by running cd hello-rust

You can now run this program by running this in your terminal:

cargo run

This will print out Hello World on your terminal as shown below

IMG_20220126_092838.jpg

Congratulations, you have successfully run your first Rust program.๐Ÿ‘

Learn more about Rust:

The book, Rust by example

Reference: Rust official website

ย