Rust01 : The Introduction

Rust01 : The Introduction

·

2 min read

What is Rust?

Rust is a General purpose programming language. Which emphasizes performance and type safety.

Rust was created as a personal project while working at Mozilla by Graydon Hoare.

It is the Most Loved Language on StackOverFlow Survey since 2016.

Rust is derived from C and C++ but it is mostly influenced by functional programming languages like Haskell, and Lisp.

Installation

First, We need to install Rustup which is Rust Version Management Tool, just like NVM for Node.

  • Go to rustup.rs.

    • Copy the Curl command and Paste it into the Terminal.

  • After installation of RustUp, Run the Command rustup default stable to install Rust in your machine.

  • Check the rust version with rustc --version

First Program

  • Create a main.rs file and paste this code snippet into the file.

      fn main() {
          println!("Hello, World!");
      }
    
  • Run rustc main.rs command. It compiles the main.rs and creates an executable binary file.

  • run the executable file with ./main

Cargo

Now, rustc is okay for single files. But for larger projects, rustc is quite difficult to work with. So We use cargo for it.

Cargo is a project management and build tool for Rust.

cargo run command executes and runs the project.

This was just the first part, More parts will be published soon. Subscribe to the newsletter to get notified whenever I post a new blog and follow me on Twitter. I post blockchain-related stuff.

Happy Hacking