The rust programming language is an open source system programming language developed by Mozilla Research. It's three main goals are: safety, speed, and concurrency. Basically it tries to be a safe and modern alternative to C.

Installing rust

There are three ways of installing rust, downloading a binary from https://www.rust-lang.org/downloads.html, or a source from the same page and compiiling it yourself. The third option is to clone the git repository at github.com, to get the stable code just run git checkout stable at the time of writing this gives you the branch containing version 1.7.

The size of the source directory will be smaller than if you downloaded from rust-lang.org, that's because the git repository contains submodules which will be pulled once you run ./configure, these submodules are already included in the tarball. These submodules are 'src/compiler-rt' 'src/jemalloc' 'src/liblibc' 'src/llvm' 'src/rt/hoedown' 'src/rust-installer' ./configure will set variables like where to install rust, which by default is under /user/local/bin. After ./configure finishes you can compile and install by running make && make install.

The install command needs to be called by root as it will put files under /user/local by defualt. This can be changed by using the --prefix option with configure.

Hello World!

Now we are ready to do some rust programming. The Rust Programming Language book is a good place to start, and rustlings is a GitHub repository with tasks to help you understand some of the more confusing parts of rust.

Hello world is super simple, just declare the main function and call the pritnln() function like this

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

Put it in a file called hello_wolrd.rs or whatever you want and compile and run it like so

-> rustc hello_world.rs
-> ./hello_world 
Hello world!

That's it!