Rust Programming

Rust Programming Langauge

Rust is a modern systems programming language created by Mozilla and OpenSource Commnunity. Rust focusses on three aspects: safety, speed, and concurrency. It does it without having a garbage collector. This makes it embeddable in other programming languages which is helps to write high performance low-level code.

Some projects built with Rust are Servo(Mozilla’s parallel browser engine), Redox OS and more

Rust won the first place for Most Loved Programming Language of 2016 in the Stack Overflow Developer Survey.

How to install rust on mac osx

Open your terminal and run

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

Once rust setup process completed, Add below command to to your bash profile(~/.bash_profile)

source ~/.cargo/env

Check if rust is installed on your mac?

relauch your terminal and run this below command. This command will print your rust compiler version on your terminal. If you get rust compiler version displayed, then you are good to go.

$ rustc --version

Hello world in rust

// This is a comment
// hello.rs

// main function
fn main() {

    // Print text to the console
    println!("Hello World!");
}

Compile and Run the rust hello world program

rustc is the Rust compiler which compiles the code into executable binary.

$ rustc hello.rs

run it with

$ ./hello
Hello World!