liveBook · Manning

Rust

As explained in Rust in Action: Systems programming concepts and techniques

Rust is a compiled systems programming language designed for memory safety, concurrency, and performance without relying on garbage collection.

Rust is a compiled language designed for systems programming but useful well beyond it. Its central promise is control over performance and memory without giving up memory safety. The compiler catches many invalid data accesses before a program runs, and Rust does not rely on a garbage collector for that safety. section 1.6 section 1.7.1

Three goals help explain Rust’s design:

  • Safety: prevent errors such as dangling pointers and data races. An out-of-bounds access instead stops the program with a panic. section 1.6.1
  • Productivity: use compiler messages and cargo to catch mistakes and manage projects. section 1.6.2
  • Control: choose how values are stored and shared when their runtime costs matter. section 1.6.3

Start with a small program: create a project with `cargo new`, edit `src/main.rs`, and execute it with `cargo run`. A greeting program uses `let` bindings, an array, a `for` loop, and `println!`. Rust strings use UTF-8, so the greetings can include German and Japanese text. The `!` marks `println!` as a macro. section 1.3.2

Listing 1.1 “Hello World!” in three languages
 fn greet_world() {
     println!("Hello, world!");                   #1
     let southern_germany = "Grüß Gott!";         #2
     let japan = "ハロー・ワールド";                    #3
     let regions = [southern_germany, japan];     #4
     for region in regions.iter() {               #5
             println!("{}", &region);             #6
     }
 }
 
 fn main() {
     greet_world();                               #7
 }

Follow the complete greeting program from its function definition through iteration and printed output. section 1.3.2

Processing records

A CSV-like penguin example splits lines into fields, trims whitespace, and parses lengths. It introduces method calls, a closure passed to `map`, type inference in `Vec<_>`, and debug output that disappears from the release run. section 1.5

Safety rules become concrete when code fails to compile. Dropping a vector and then printing it produces a “borrow of moved value” error; trying to change the same local value from spawned threads also fails. These messages are clues to investigate, not signs that every software bug is impossible. section 1.6.1 section 1.8.5

Rust suits command-line utilities that need quick startup, low memory use, and easy distribution. It also appears in data processing, server applications, constrained devices, and operating-system work. It is not always the easiest choice: cyclic structures can be awkward, the compiler is strict, and the language takes time to learn. Start with a small subset and add features as needed. section 1.10.1 section 1.8.4 section 1.8.1

How Rust in Action: Systems programming concepts and techniques covers it

How deep it goes
Works through introductory syntax and compiler errors, while deferring advanced language concepts and fuller concurrency treatment.
Examples
Uses multilingual greetings and CSV-like penguin records to demonstrate iteration, strings, methods, closures, and program output.
What it assumes
Assumes some programming experience but introduces systems topics such as operating systems, CPUs, pointers, and data types.
What you can do after
Build it from scratch: create and run a multilingual greeting program with cargo, then read a small data-processing program.
How it connects
Connects borrowing to dangling pointers, threads to data races, and storage choices to stack, heap, and reference counting.

Also explained in

Compare how 6 books explain Rust →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Rust in Action: Systems programming concepts and techniques. The section links point to the parts of the book it draws on.