"Command-Line Rust" by Ken Youens-Clark

You can definitely feel that the author has a lot of experience writing high-quality production code. 

"Command-Line Rust" by Ken Youens-Clark

This post is part of my Book reviews series, where I share thoughts and impressions on the books I read.

"Command-Line Rust" is authored by Ken Youens-Clark and published by O'Reilly.

Writing command line programs in Rust. 

You take an existing CLI program on Unix, e.g "ls","cat", "find" or "grep", and you then write a simple version of it using pure Rust and some helper crates.

Each chapter, 14 in total, takes you through writing one specific classic Unix command-line tool.

The chapters begin with the description of the original program, showing an excerpt of its man pages for both GNU and BSD versions (more on this later). 

Then you're shown tests written by the author which you would ideally pass, in order to arrive at a valid solution which replicates part of the original program. 

After that the author proceeds to give a function by function run through of his suggested solution, guiding you through the more complex code pieces and also gradually introducing more Rust structures and concepts.

👩‍💻🧑‍💻Who is this book for?

Experienced programmers, especially those who have previous experience with Linux and it's command line tools.

The explanations are well structured, especially around the pieces of code which are more complicated or which use new language concepts or constructs. 

Taking a TDD (test-driven development) approach to writing the code, showing first the tests that need to pass and then writing the functions to make them pass.

In the repo there are nice bash scripts to setup the files needed for the tests.

Code is written idiomatically and teaches you how to write and think like a Rustacean.

You can definitely feel that the author has a lot of experience writing high-quality production code. 

There's quite a bit of what I consider to be filler text. The body of the "main" function is always repeated in each chapter, as well as the main function which gets the user input from the command line. These could have easily been skipped, probably it would have reduced the size of the book by quite a bit.

As well, the tests are generally very simple and straightforward, and I would have also removed 80% of them from the book, and simply point the reader to the GitHub repo of the book.

There is also the printing of the man pages for the original CLI programs in both GNU and BSD versions. I don't think that this was a good decision, as the differences are really minimal and having to read through 2 pages of explanations only confuses the reader with irrelevant information.

🤔Final thoughts
I'm very grateful to Ken Youens-Clark for putting in the work and effort to write it, especially seeing how few quality books are out there on intermediate and expert-level Rust. 

The quality of O'Reilly books is as always top notch, definitely the best in the market, especially compared to that of Packt or Apress - which are frankly abysmal.