
Rust is a new systems programming language that combines the performance and low-level control of C and C++ with memory safety and thread safety. Rustâ s modern, flexible types ensure your program is free of null pointer dereferences, double frees, dangling pointers, and similar bugs, all at compile time, without runtime overhead. In multi-threaded code, Rust catches data races at compile time, making concurrency much easier to use. Written by two experienced systems programmers, this book explains how Rust manages to bridge the gap between performance and safety, and how you can take advantage of it. Topics include: How Rust represents values in memory (with diagrams) Complete explanations of ownership, moves, borrows, and lifetimes Cargo, rustdoc, unit tests, and how to publish your code on crates.io, Rustâ s public package repository High-level features like generic code, closures, collections, and iterators that make Rust productive and flexible Concurrency in Rust: threads, mutexes, channels, and atomics, all much safer to use than in C or C++ Unsafe code, and how to preserve the integrity of ordinary code that uses it Extended examples illustrating how pieces of the language fit together
I also implemented Nand2Tetris part 1 in SystemVerilog, have it running on an FPGA and almost completed extending as a toy SoC. I wrote the assembler and UART loader in Rust, but I still need to write the UART FSM that replaces the program in "ROM".
https://github.com/MSamman/hack-soc
Also, if you find TRPL a little slow, Programming Rust goes faster, a bit deeper and I found to be a bit more engaging of a read.
Lastly I recommend reading Programming Rust. It is long but extremely thorough! You’ll understand the language at a deep level. Good luck and have fun!
I think Amos's title here is a little tongue-in-cheek by the way - it's more like a half-hour to skim through it, but with this at hand you'll be in a much better place to start writing some toy rust programs before you dive into more in-depth books like "The Rust Programming Language".
I currently have (and like) that and the O'Reilly book "Programming Rust", and found them sufficient for initial exploration. I'm now trying to internalise the contents of "Effective Rust" (also O'Reilly) and "Rust for Rustaceans" from Free Starch Press - the latter of which I would say is the most advanced of these.
There's still plenty I don't understand, but that's more about the minimal amount of time I've spent dabbling rather than any deficiency in these resources (so far as a dabbler can tell).
I found it more approachable than some of the other Rust books and highly recommend it as a first Rust book.
I tried reading "The Rust Programming Language" book, but had difficulty with it.
The book that worked for me was "Programming Rust": https://www.oreilly.com/library/view/programming-rust-2nd/97...
The way that it explained things made more sense to me and helped me to understand many of the design decisions behind why Rust works the way that it does.
But reading books only takes you so far. You need to write code and read code to understand through experience. I took a C program that I wrote at my job and rewrote it in Rust. It was a revelation: in writing the Rust version I discovered many bugs that were not obvious in the C version simply because of Rust's detailed approach to error handling. The Rust version was much easier to understand and maintain and is the one we use now.
I was originally very skeptical of Rust, but if you write software in C or C++ and then write comparable software in Rust, it makes you want to use Rust every time instead. Rust code helps prevent errors of all types that C and C++ allow. Rust tooling and the ecosystem of crates are so much easier to use.
Here is a quote from "Programming Rust" that I found motivating:
The Rust language makes you a simple promise: if your program passes the compiler’s checks, it is free of undefined behavior. Dangling pointers, double-frees, and null pointer dereferences are all caught at compile time. Array references are secured with a mix of compile-time and run-time checks, so there are no buffer overruns: the Rust equivalent of our unfortunate C program exits safely with an error message.
Further, Rust aims to be both safe and pleasant to use. In order to make stronger guarantees about your program’s behavior, Rust imposes more restrictions on your code than C and C++ do, and these restrictions take practice and experience to get used to. But the language overall is flexible and expressive. This is attested to by the breadth of code written in Rust and the range of application areas to which it is being applied.
In our experience, being able to trust the language to catch more mistakes encourages us to try more ambitious projects. Modifying large, complex programs is less risky when you know that issues of memory management and pointer validity are taken care of. And debugging is much simpler when the potential consequences of a bug don’t include corrupting unrelated parts of your program.
Of course, there are still plenty of bugs that Rust cannot detect. But in practice, taking undefined behavior off the table substantially changes the character of development for the better.