The Rust Programming Language, 2nd Ed

Author: Steve Klabnik and Carol Nichols
Publisher: No Starch Press
Date: June 2023
Pages: 560
ISBN: 978-1718503106
Print: 1718503105
Kindle: B0B7QTX8LL
Audience: Systems programmers
Rating: 4.8
Reviewer: Mike James

There's a new edition of what has become the standard text on Rust. Has it matured along with Rust?

This is the standard book on the subject in the sense that it is written by members of the Rust team. This second edition is unchanged in structure and approach from the previous edition what is important is that it has been brought up-to-date with Rust 2021.  It is also more or less part of the standard documentation and you can read versions of the book at the Rust website. 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.       

Banner

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.

Banner


Python All-in-One, 2nd Ed (For Dummies)

Authors: John Shovic and Alan Simpson
Publisher: For Dummies
Date: April 2021
Pages: 720
ISBN: 978-1119787600
Print: 1119787602
Kindle: B091DGDLK8
Audience: People wanting to learn Python
Rating: 2
Reviewer: Mike James
All-in-one refers to the fact that this is seven books put together - why?



Lean DevOps

Author: Robert Benefield
Publisher: Addison-Wesley
Pages: 368
ISBN: 978-0133847505
Print:  0133847500
Kindle: B0B126ST43
Audience: Managers of devops teams
Rating: 3 for developers, 4.5 for managers
Reviewer: Kay Ewbank

The problem this book sets out to address is that of how to deliver on-demand se [ ... ]


More Reviews

Last Updated ( Tuesday, 15 August 2023 )