Learning Rust
350 pages
English
PDF
4.5

Learning Rust

Learning Rust

Author:

Year:

Summary:

Introduction

The book "Learning Rust", written by Paul Johnson and Vesa Kaihlavirta and published in 2017 by Packt Publishing, is one of the first practical guides to the Rust language on both the Russian-speaking and English-speaking markets. Over 350 pages, the authors attempt to guide the reader from the basics of syntax to creating real applications, paying special attention to memory safety and concurrency — Rust's key features. For the PythonLib educational website, aimed at a broad audience of developers, this book is interesting as an example of transitioning from high-level languages (Python, JavaScript) to systems programming without losing performance and with safety guarantees.

What the book is about

"Learning Rust" is structured as a sequential introduction to the Rust ecosystem. The first chapters cover tool installation, basic syntax, the ownership system, borrowing, and lifetimes. The authors then move on to more complex topics: generics, traits, error handling, the module system, and testing. Separate chapters cover working with collections, input/output, macros, and FFI (Foreign Function Interface). The book concludes with building a small web application using the Iron framework (now outdated) and examples of asynchronous programming.

Who this book is for

The book is intended for developers who already have programming experience in C, C++, Python, or Java. It will be difficult for programming beginners: the authors do not explain basic concepts (loops, functions, data types) from scratch, but immediately move on to Rust's features. However, for those who want to learn systems programming with modern approaches to safety, this is an excellent start.

What the reader will learn

  • Rust syntax basics: variables, functions, control constructs, ownership and borrowing.
  • Type system: generics, traits, static dispatch, lifetimes.
  • Memory management: principles of ownership, borrowing, and lifetimes without a garbage collector.
  • Error handling: using Result and Option, the ? operator.
  • Modularity and testing: code organization, unit tests, documentation tests.
  • Concurrency: threads, channels, mutexes, safe state sharing.
  • Macros: declarative and procedural macros.
  • Interfacing with C: FFI, calling C functions from Rust and vice versa.
  • Building a web application: basics of working with HTTP, routing, templating.

Strengths

One of the book's main advantages is its practical focus. Each chapter contains code examples that can be run immediately, and exercises to reinforce the material. The authors devote a lot of attention to explaining the ownership system — the most difficult concept for beginners — using clear diagrams and analogies. Also worth noting is the chapter on FFI, which is rarely found in introductory courses but is extremely useful for systems programmers. The book is written in a lively style, without excessive academicism, which makes it easier to understand.

Weaknesses

The main drawback is the book's age. Rust is actively evolving, and since 2017 the language has undergone significant changes: the Iron framework has become outdated, new features have appeared (e.g., async/await, many libraries have been stabilized). Some examples may not compile on the current version of the compiler. Additionally, the book does not cover important topics such as async/await, WebAssembly, embedded programming, and working with popular crates (e.g., serde, tokio). The first part may be too challenging for beginners.

Recommendations