liveBook · Manning

Chapter 1: Introducing Rust

What you will learn in chapter 1 of Rust in Action: Systems programming concepts and techniques

The chapter introduction welcomes readers and previews the book’s practical Rust projects and systems-programming topics.

After this chapter you will be able to

Section by section

Introduction

The chapter introduction welcomes readers and previews the book’s practical Rust projects and systems-programming topics.

1.1 Where is Rust used?

This section shows that Rust is used in a wide range of production systems by both large technology companies and fast-moving startups.

Key terms: Rust, AWS Lambda, Firefox, startups, Sourcegraph, Figma, Parity

1.2 Advocating for Rust at work

The section describes how engineers have introduced Rust at work through small projects and used those successes to support wider adoption.

Key terms: bottom up, technical challenges, small projects, Google, Android, Fuchsia, officially sanctioned language

1.3 A taste of the language

Introduces a hands-on taste of Rust using the compiler and a quick program, with full projects reserved for later chapters.

1.3.1 Cheating your way to “Hello, world!”

This section uses Cargo’s generated project to run “Hello, world!” without writing Rust code, then explains the files and build steps involved.

Key terms: cargo new, Cargo.toml, src, .rs, cargo run, debug mode, src/main.rs, Cargo.lock, target/

1.3.2 Your first Rust program

This section walks through creating and running a multilingual greeting program, then explains its UTF-8 strings and the exclamation mark in `println!`.

Key terms: cargo new, src/main.rs, cargo run, strings, UTF-8, println!, macro, boilerplate code

1.4 Downloading the book’s source code

The section tells readers where to get the example source code so they can follow along with the book.

Key terms: source code, listings

1.5 What does Rust look and feel like?

The section uses a CSV-processing example to show Rust’s high-level feel, explain several pieces of its syntax, and demonstrate how to run debug and release builds.

Key terms: method syntax, closure, expression-based language, bare-metal performance, Vec<_>, vector, type inference, println!, eprintln!, stdout

1.6 What is Rust?

The section introduces Rust through its compile-time memory safety, its inclusive community, and its usefulness beyond traditional systems programming.

Key terms: invalid data access, compile time, memory-safe, runtime costs, inclusion, code of conduct, compiler’s error messages, systems programming language, safety, productivity

1.6.1 Goal of Rust: Safety

This section illustrates Rust’s safety goal through examples of invalid references, data races, out-of-bounds access, iterator invalidation, and integer overflow.

Key terms: dangling pointer, borrow, moved value, data race, thread, thread::spawn(), fearless concurrency, buffer overflow, fruit[4], iterator invalidation

1.6.2 Goal of Rust: Productivity

The section illustrates Rust’s productivity goal through a compiler-caught assignment mistake and the project utilities provided by cargo.

Key terms: assignment, equality, unit, (), mismatched types, cargo, rustc, cargo new, cargo init, cargo build

1.6.3 Goal of Rust: Control

This section explains that Rust gives programmers control over data representation and access patterns while treating safety as its first priority.

Key terms: control, access patterns, runtime characteristics, trade-offs, safety, immutable by default, compile-time checks, zero-cost abstraction

1.7 Rust’s big features

Introduces performance, concurrency, and memory efficiency as Rust features to be discussed next.

1.7.1 Performance

This section explains how Rust pursues performance through compiler optimization, data layout, and static dispatch, while noting its package ecosystem.

Key terms: compiler, optimizes, performance, cache-friendly data structures, arrays, data-oriented programming, static dispatch, dynamic dispatch, methods, cargo

1.7.2 Concurrency

The section presents Rust’s approach to concurrency as extending safety across threads without a global interpreter lock.

Key terms: fearless concurrency, threads of execution, global interpreter lock (GIL)

1.7.3 Memory efficiency

This section explains how Rust supports low-memory programs while keeping high-level constructs inexpensive at runtime.

Key terms: fixed-size structures, iteration, generic types, runtime overhead

1.8 Downsides of Rust

This introduction cautions that Rust’s appealing claims do not make it a cure-all and sets up a discussion of its disadvantages.

Key terms: panacea, disadvantages, slogans

1.8.1 Cyclic data structures

This subsection identifies cyclic data structures as difficult to implement in Rust and advises newcomers to postpone them.

Key terms: cyclic data, arbitrary graph structure, doubly-linked list, safety checks

1.8.2 Compile times

This subsection explains why Rust can compile more slowly than peer languages and the optimization tradeoff involved.

Key terms: crate, module, whole-of-crate optimization, LLVM

1.8.3 Strictness

This section presents Rust’s strict compiler as a short-term inconvenience that can catch mistakes before users encounter crashes.

Key terms: compiler, strict, compile, dynamic language

1.8.4 Size of the language

Rust’s size makes it challenging to learn, so the book introduces the language gradually.

Key terms: rich type system, steep learning curve, minimal subset

1.8.5 Hype

This subsection cautions against treating Rust’s popularity as proof that it can solve every software problem.

Key terms: hype, security problems, panacea

1.9 TLS security case studies

The section introduces two SSL/TLS security cases to show that Rust may help prevent serious errors but cannot eliminate them all.

Key terms: Rust, memory safety, Heartbleed, goto fail;

1.9.1 Heartbleed

Explains how reusing an uncleared buffer can leak earlier users’ data and why Rust’s protections do not prevent every security flaw.

Key terms: Heartbleed, buffer, leak, performance, logical errors, security issues

1.9.2 Goto fail;

This section uses the goto fail; security bug to show how C syntax can let a programmer’s mistake skip cryptographic checks, while explaining how Rust would help without making mistakes impossible.

Key terms: goto fail;, logical tests, curly braces, cryptographic key pair, Rust’s grammar, unreachable

1.10 Where does Rust fit best?

1.10.1 Command-line utilities

This subsection explains why Rust is well suited to command-line utilities: quick startup, low memory use, and easy deployment.

Key terms: startup time, interpreter, virtual machine, bare metal language, memory-efficient, zero-sized, static binaries, shared libraries, deployment

1.10.2 Data processing

This section explains why Rust is useful for data processing, from text filters to high-throughput pipelines.

Key terms: data wrangling, type system, high throughput data pipelines, memory footprint, filter programs, Apache Storm, Apache Kafka, Apache Hadoop streaming

1.10.3 Extending applications

This section explains why Rust is useful for extending applications written in dynamic languages and gives two examples of its use.

Key terms: dynamic language, JNI, C extensions, Erlang/Elixir NIFs, memory leak, Sentry, Dropbox, CPU-intensive components, file synchronization engine, correctness

1.10.4 Resource-constrained environments

This subsection explains why Rust is appealing for network-connected devices with limited resources.

Key terms: Internet of Things (IoT), input parsing code, firmware updates, runtime costs

1.10.5 Server-side applications

This section shows that Rust is used for server-side applications and for services that support them, with examples from registries, databases, and search.

Key terms: server, services, databases, monitoring systems, search appliances, messaging systems

1.10.6 Desktop applications

This subsection explains that Rust can be used to build user-facing desktop software.

Key terms: user-facing software, Servo, games

1.10.7 Desktop

This subsection explains why Rust may appeal to desktop application developers and predicts how its adoption could grow.

Key terms: desktop applications, deployment, rigor, ecosystem

1.10.8 Mobile

This subsection explains how Rust can run on phones through the native-application interface rather than a platform’s usual development path.

Key terms: native applications, C++, runtime cost

1.10.9 Web

This section presents WebAssembly as a way to bring Rust projects to the browser.

Key terms: WebAssembly (Wasm), compiler target, Rust

1.10.10 Systems programming

This subsection presents systems programming as a central use of Rust, illustrated by substantial software projects and industry efforts.

Key terms: systems programming, compilers, operating systems, low-level components

1.11 Rust’s hidden feature: Its community

The section presents Rust’s welcoming community as an important part of the language’s success.

Key terms: community, courtesy and respect

1.12 Rust phrase book

Defines five common Rust phrases that express the community’s values and the language’s promises about performance, concurrency, compatibility, and abstraction.

Key terms: Empowering everyone, Blazingly fast, Zero-cost abstractions, Fearless concurrency, No Rust 2.0, semantic versioning, backward-incompatible

1.13 Summary

Where this is used later

Concepts explained in this chapter

Chapter 2: Language foundations →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.