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.
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
./configure will set variables like where to install rust, which
by default is under /user/local/bin.
./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
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
Put it in a file called hello_wolrd.rs or whatever you want and compile and run it like so