I first came across Rust because it was born out of an attempt to rewrite the rendering engine behind Firefox, a project named Servo. Recently Rust won the “most loved language” for the second year in a row (see Stack Overflow Developer Survey 2017). The best way to learn Rust is by reading the second edition of the official book.

One of the first things you’ll notice is that println is a macro, not a function. More generally, this is how metaprogramming is done in Rust. For example, if you would like to write a routine that takes a variable number of arguments or has default values you’ll need to write a macro.

Another important bit of syntax is the semicolon, which terminates an expression.

Cargo can be used to create a project, build the code, download and manage dependencies. This becomes increasingly important because the standard library in Rust is relatively small. When creating a project use --bin to specify building a application. Cargo will initialize a git repository by default. It manages dependencies for a project by generating a Cargo.lock file.

// A string literal is simply an immutable String reference
let sl = "Hello world";
// Create a String from a string literal
let s = String::from("Hello world");
struct Person {
    name: String
let name = String::from("John");
Person {name};
use std::collections::HashMap;

let teams  = vec![String::from("Blue"), String::from("Yellow")];
let initial_scores = vec![10, 50];

let scores: HashMap<_, _> = teams.iter().zip(initial_scores.iter()).collect();

Comparison to C