Sunday, October 30, 2016

Installing Rust On Ubuntu 16.04 and 14.04

Installing Rust On Ubuntu 16.04 and 14.04


Rust Programming Logo

Rust, also known as Rust-Lang, is a new programming language which aims safety, speed and concurrency... It's designed to create highly concurrent and secure Applications/Systems by having more a number of compile-time safety checks that produce no runtime overhead, while eliminating all data races.... According to documentation, Rust also aims to achieve ‘zero-cost abstractions’ even though some of these abstractions feel like those of a high-level language.

Here.. We are going to see how to install and getting start with rust on Ubuntu Linux 16.04 & 14.04

Step 1: Update Source(Package) List

Open terminal and run the following commands to ensure that package source list is upto date and also install curl...

For Ubuntu 16.04

sudo apt update && sudo apt -y install curl

For Ubuntu 14.04

sudo apt-get update && sudo apt-get -y install curl

Step 2: Install Rust

Now run the following command which download and runs a script that will install rust on your Linux box..

wget -O - https://static.rust-lang.org/rustup.sh | sh

Or If you have curl installed..

curl -sSf https://static.rust-lang.org/rustup.sh | sh

Rust packages are available in three different release channels namely stable, beta and nightly... The above command will install current stable version of rust on your system..

If you want to install beta version(A preview of the upcoming stable release, intended for testing) of rust, run the following command..

wget -O - https://static.rust-lang.org/rustup.sh | sh -s -- --channel=beta

Or

curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=beta

If you want to enjoy features that are not available in stable and beta channels, install rust from nightly release channel.. (Be aware, Features which are available in nightly channel are unstable may change anytime before they get into beta channel)

wget -O - https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly

Or

curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly

Step 3: Verify The Installation

You can verify the successful installation of rust in your System by running rustc -V . You will get output similar to output shown below..

shivaraj@shivaraj-A14RM0E:~$ rustc -V rustc 1.12.1 (d4f39402a 2016-10-19)

Get start with rust..

If you see output similar to above.. that means your installation was successful.. So now here i am going to show how to write a hello world program in rust and run it..

Create file named main.rs, open it with your favorite text-editor, then copy and paste the following code in that file and save it...

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

Now compile it with rustc main.rs, you will get executable file named main .... execute it by running ./main .. You will see.. "Hello, World" text on your screen..

shivaraj@shivaraj-A14RM0E:~$ ./main Hello, World shivaraj@shivaraj-A14RM0E:~$

Here, You Can Learn Rust Programming..


Here is the video for above tutorial...



Happy Coding !!