This practical book introduces systems programmers to Rust, the new and cutting-edge language that’s still in the experimental/lab stage. You’ll learn how Rust offers the rare and valuable combination of statically verified memory safety and low-level control—imagine C++, but without dangling pointers, more » null pointer dereferences, leaks, or buffer overruns.
Author Jim Blandy—the maintainer of GNU Emacs and GNU Guile—demonstrates how Rust has the potential to be the first usable programming language that brings the benefits of an expressive modern type system to systems programming. Rust’s rules for borrowing, mutability, ownership, and moves versus copies will be unfamiliar to most systems programmers, but they’re key to Rust’s unique advantages.
This book presents Rust’s rules clearly and economically; elaborates on their consequences; and shows you how to express the programs you want to write in terms that Rust can prove are free of broad classes of everyday errors. « less
Discover how to use Rust to write fast, secure, and concurrent systems and applications
ABOUT THIS BOOK
* Learn how to create secure and blazingly fast programs in Rust
* Start working with Rust in a multicore and distributed environment
* Explore the core characteristics of Rust - safety, performance, and concurrency - to build error free and robust code
WHO THIS BOOK IS FOR
WHAT YOU WILL LEARN
* Set up your Rust environment for maximum productivity
* Bridge the performance gap between safe and unsafe languages with Rust
* Use pattern matching to create flexible code
* Apply generics and traits to develop widely applicable code
* Organize your code in modules and crates
* Build macros to extend Rust's capabilities and reach
* Apply threads to tackle problems concurrently and in distributed environments
* Interface with C and isolate unsafe code
Starting by comparing Rust with other programming languages, this book will show you where and how to use Rust. It will discuss primitive types along with variables and their scope, binding and casting, simple functions, and ways to control execution flow in a program.
Next, the book covers flexible arrays, vectors, tuples, enums, and structs. You will then generalize the code with higher-order functions and generics applying it to closures, iterators, consumers, and so on. Memory safety is ensured by the compiler by using references, pointers, boxes, reference counting, and atomic reference counting. You will learn how to build macros and crates and discover concurrency for multicore execution.
By the end of this book, you will have successfully migrated to using Rust and will be able to use it as your main programming language. « less