Rust

What the hell is Rust? Well, it turns out Rust is an up-and-coming systems programming language that is currently still in alpha. To be completely honest, I don't know the first thing about Rust, but you gotta start somewhere.

Installation

Lets take a look at the installation methods for Rust so you too can be a rustacean (odd moniker, but catchy). Your first option is to visit the Rust Programming Language website and, if you're running OS X, just click on the blue download button. If you're using another operating system, click on 'Other Downloads' and pick up the correct version.

If you plan on developing anything in Rust, and want to keep up with the latest nightlys, I recommend using your terminal and installing from with, $ curl -s https://static.rust-lang.org/rustup.sh | sudo sh

Once the installation is finished running, type
$ rustc --version to make sure it's installed. You can also check the commit date from there. Now you are all set!

Hello, world!

It's been awhile since I've done one of these, but it's always exciting! So let's hop into a test folder, throw a $ mkdir test and $ cd test into that folder and create a test.rs in that folder with whatever method you want ($ touch test.rs). You can tell that rust files will end in a .rs extension. When you are in the file type

fn main () {  
    println!("Hello, world!")
}

Go ahead and save that file and jump back into your terminal. There are a few important pieces of this function that we need to examine.

  • fn main() is special because it marks the beginning of every Rust program
  • The method or function call look similar to JavaScript as well as the brackets, but what's the deal with the ! after println? That signifies a macro and is something we will dive much further into later

Finally, jump back into your terminal, compile your Rust file with $ rustc test.rs and run the test executable by running ./ test and witness the glory! woot!

Alright guys go check out the Rust docs and stay tuned because we're going head-first into the beauty that is Rust.

Tags

Rust Programming Language , Rust

About the author
comments powered by Disqus