Installing A Rust Programming Environment
Before you begin, you need to install both Rust and Cargo on your system. They should both be available in your Linux distribution's software repository.
A software repository is a collection of packages available on a central server for download via a package manager. Linux distributions are operating systems whose sole mean of installing software is through these software repositories designed specifically for each distribution. Some Linux distributions feature more complete collections of software than others. I highly recommend a distribution from the Arch Linux family, such as Antergos).
If your operating system does not offer either, you can find instructions available at Rust's official website. Installing Rust typically also installs Cargo alongside it when using the official method.
The Rust Package
The Rust package contains the entirety of the Rust Standard Library alongside the rustc Rust compiler.
A library is simply a collection of public functions that are made available to any application which imports them into their project. A compiler is a program that takes source code as input and translates it into a lower-level language, normally Assembly. They are used to convert source code into machine code, ultimately.
Cargo Package Manager
If you are writing is a simple calculator without any external dependencies, rustc is all you need. However, you will need to use Cargo for package management of larger projects, as doing so with rustc is a bit more difficult.
The idea behind package managers is that users and developers shouldn't have to manually track down dependencies when installing new software. Instead, there should be a package manager that knows what dependencies are required that will automatically download, compile and/or install them.
As a package manager, Cargo reads from a single file, named Cargo.toml
, in the root directory of your Cargo project to decide what dependencies are needed to be installed for your project. Before it begins compiling your project, it will download and compile all of the libraries listed under [dependencies]
to get them ready for linking into your project's binary, if you are writing a binary. It will also recurse into the dependencies of your dependencies and grab them as well. If, instead, you are writing a library, no compiling is required at all.
Cargo also goes well beyond simple package management and also features the capability to automatically generate documentation for all libraries imported into a project using the
doc
argument. This documentation can then be viewed from a web browser or even hosted on a web server for others to view. This is the future of API documentation.
Crates.io: Universal Crate Repository
As you may have already noticed, Cargo hosts a universal community repository for Rust crates that can automatically download and build at compile time for your Rust projects at crates.io. A crate is simply a fancy term for a Rust software library, also known as an rlib. In your Cargo.toml
file, you can specify what crates that you want in your project, as well as what version of each crate that you want. Cargo may also access private and public git repositories, allowing you to specify which commit or branch of the git repository you want to build with.
Crates To Be Used
Getting an Integrated Development Environment
Integrated Development Environments are available for Rust today, and the current best-supported IDE is actually the Atom Editor in combination with Racer and terminal-plus.
After setting up all of these things, you'll be ready to start this project.