Getting Started
This chapter introduces the core concepts required to create, compile, and run Rust executables and libraries. This includes completing your first Rust application—the illustrious “Hello, World” application. When learning a programming language, this application is often the first example. It is a great tool for learning a new programming language. The first documented example of this familiar application is found in the book The C Programming Language from Brian Kernighan and Dennis Ritchie back in 1972. Who are we to break tradition?
Several variations of the “Hello, World” application will be presented here while we explore different “getting started” topics.
We will also continue exploring the Rust toolchain in this chapter. Knowledge of the tools in the toolchain, such as Cargo and Rustc, is essential to productive interaction with the Rust environment. For this reason, components of the toolchain are introduced here.
Preliminaries
Before we create our first application, Rust must be installed. Rustup is the Rust installer and toolchain manager. Rustup manages the proper installation for specific platforms.
By default, Rustup installs the latest stable build, also called a channel. At the moment, Rust is on a six-week release cycle. The upcoming release schedule is published at Rust Forge (https://forge.rust-lang.org/). The following are the three available channels:
Stable: The latest release
Beta: The next version available with the upcoming release
Nightly: The nightly build, which includes experimental features
You can also request that Rustup install specific versions of the Rust environment. This is especially useful if your organization has not upgraded to the latest release.
Different methods are available to install Rust. Each requires a different level of user involvement, from minimal to moderate. For a standard installation, choose a minimal approach. However, more involvement is required if you want to customize the installation.