The Rust Programming Language

Author: Steve Klabnik and Carol Nichols
Publisher: No Starch Press
Date: June 2018
Pages: 552
ISBN: 978-1593278281
Print: 1593278284
Kindle: B071YKRV8Q
Audience: Systems programmers
Rating: 4.8
Reviewer: Mike James

Rust has been getting a lot of attention - what's the fuss all about? This is the standard book on the subject so let's find out.

This is the standard book on the subject in the sense that it is written by members of the Rust team and as the back jacket says:

"This is the undisputed go-to guide to Rust, written by two members of the Rust core team, with feedback and contributions from 42 members of the community."

It is also more or less part of the standard documentation and you can read the book at the Rust web site. It is true to say that the book has a lot of love and dedication from the enthusiastic Rust community - what about from an outsider wanting to know about Rust?

Despite my seemingly grumpy complaints about Rust and the book - my overall verdict is that it is the one to buy. Keep this in mind as you read on.

The book isn't aimed at the complete beginner and you are expected to know how to program, but not in any particular language. I also think that you have to assume that the potential reader is motivated to learn something about what makes Rust special. After all, if you already know how to program and have mastered another language one of the first things you are going to want to know is why bother with a new language?

One of the things that the book fails to deliver on in its first 56 pages is to give the reader the idea why Rust is an important language. The first three chapters take you over the basics of the language as if it was any other language. We get a simple introduction to the environment - cute terms like cargo, crates and so on, and a return to the command line, feature. I get the fact that Rust is targeted at systems programmer, but this is the 21st century - no modern language should be delivered to its end users without some sort of IDE. Modern languages are no longer just syntax and semantics baked into a compiler, they are toolsets and environments. Programming is hard enough without throwing us back to the command line. If you don't agree with this sentiment, and many don't, then you won't object to Rust's and the book's approach.       


My advice is to quickly skim read the first three chapters. They tell you about the basics and most of this is obvious.

It is not until Chapter 4, on ownership as a way of doing memory management. that the moderately capable programmer starts to find out what is special about Rust. Ownership is the first deep idea you will encounter and it might even be the only deep idea that Rust brings to the table. There are others but they are minor fixes compared to the way memory is managed. This chapter make the problem with the book very clear - for the capable programmer it is simply too long. It is difficult to pull out the principles from the many examples given and the slow introduction to how things work. On the other hand, if this is what you are looking for then this is a plus not a minus.

Does the chapter manage to get across the all important idea of ownership, borrowing, mutable v immutable and slices? More-or-less, but I was really looking for a clear summary at the end of the chapter and there wasn't one.

From here the book settles back into explaining Rust as if it was just another programming language. Chapter 5 is on structs - which are not quite like those in C, so be careful. Chapter 6 covers enums and pattern matching - again this might be new if you haven't used a modern functional language. Chapter 7 is on modules and chapter 8 is on collections. All stuff you need to know, but not exciting or very different and the big problem with Rust and this book is picking out the differences from the accounts of what you all ready know.

The next two chapters deserve your undivided attention. Rust does errors differently and it is a good approach and well explained in the book. Chapter 9 explains the ideas in a fairly concise manner. Chapter 10 explains traits and generics - pay attention. After this we are back on the standard track - tests, a project, functional aspects and more on cargo and crates.

The next two chapters again are a wake up call. Chapter 15 is on smart pointers and Chapter 16 is titled "Fearless concurrency". Here the idea is that you can just "use" concurrency without the usual deep feeling of unease because ownership, immutability and other more minor changes make Rust concurrency safe. Well, what it actually means is that there is a good chance of picking up the more obvious concurrency problems as compile time errors - which is a big improvement. The chapter explains about channels, threads, ownership and mutexes. I'd like to see an example where things do go wrong just to draw the boundaries of what is and isn't made safe by the approach that the language takes. It isn't enough in this case to see what has been fixed. Coding concurrent or parallel programs always gives you a feeling that something might be going on that you haven't taken into account and seeing an example of deadlock, starvation or any of the other terrors of concurrent programming might settle the mind enough to be fearless.



The last few chapters deal with object-oriented features of Rust, pattern matching and advanced features. The final chapter takes the form of an extended example - a multi-threaded web server. The book ends with some useful appendices.

This book has been compared to K&R and praised as being almost perfect. It isn't comparable to K&R because it isn't concise. What made K&R such a model for writing books on simple languages is that it got to the point fast and told you what you needed to know. This book tells you what you need to know, but you have to read about a lot of things you do know on the way. Of course, there is always the possibility that you don't know quite as much in which case the book will hand-hold you through some difficult bits.

The book is good and highly recommended, but it isn't a quick introduction for competent programmers wanting to know the key ideas of Rust.  


To keep up with our coverage of books for programmers, follow @bookwatchiprog on Twitter or subscribe to I Programmer's Books RSS feed for each day's new addition to Book Watch and for new reviews.


Street Coder (Manning)

Author: Sedat Kapanoglu
Publisher: Manning
Date: February 2022
Pages: 272
ISBN: 978-1617298370
Print: 1617298379
Kindle: B09Q3PJQC5
Audience: General
Rating: 4
Reviewer: Ian Elliot
Street Coder - sounds sort of tough but messy at the same time.

Graph Databases in Action (Manning)

Author:  Dave Bechberger and Josh Perryman
Publisher: Manning
Pages: 366
ISBN: 978-1617296376
Print: 1617296376
Audience: Developers interested in graph databases
Rating: 4.5
Reviewer: Kay Ewbank

This book sets out to give developers building applications using graph databases an understanding o [ ... ]

More Reviews

Last Updated ( Saturday, 01 September 2018 )