REVIEW - Embracing Modern C++ Safely


Embracing Modern C++ Safely


John Lakos, Vittorio Romeo, Rostislav Khlebnikov, Alisdair Meredith


Addison-Wesley Professional (2021)




Emyr Williams


March 2023



Verdict: Highly recommended

It’s been 11 years since we got C++11 and around 7 or 8 years since we got C++14. And I’d be willing to bet that many companies won’t have migrated their code bases from C++ 03 or before, to the later versions. This is a very welcome book, which should encourage developers to migrate in a controlled manner from pre-C++11 code bases to a more modern compiler. And that is who this book is firmly aimed at. It most certainly is not someone who’s just starting out on their C++ journey. The authors assume a depth of knowledge on the part of the reader.

The book is broken up in to three chapters, which is a bit odd given it’s such a large book. So it may be better to think of them as sections rather than chapters, but these break down in to the following:

  1. Safe features – Features that add value and are difficult to misuse unintentionally.
  2. Conditionally Safe Features – Features that aren’t obvious in how to use them appropriately or optimally.
  3. Unsafe Features – Features that widespread use would be counterproductive in typical large software projects.

With that in mind, the authors take great pains to present the cold facts in regards to that feature, rather than their opinions. It is evident that the authors have learned all this the hard way, and it clearly shows.

They do not just give a cursory explanation as to why/how you should use a given feature. They do a deep dive on each feature, as well as covering the use cases, the pitfalls of using the feature, annoyances, as well as the edge cases of that features, as well as the pitfalls that feature could cause, so there’s plenty for the coder to get their teeth into here.

I also enjoyed the fact that the code samples aren’t contrived. But real-world examples. I struggle with abstract things, I need to see something in action to understand it, and this, at least for me, is one of the stronger elements of the book. There’s simple code as well as more complex examples, and clear explanations as to what’s going on.

I also like the fact that you can read this in any order you wish. And in fact, I’d say that’s the best way to read it. Each feature is its own self-contained ‘chapter’ if you like, so if you want to look up why ‘friend’ is considered unsafe, then you could do so.

While this book is primarily about C++ 11/C++14 there is an eye on the future too, and there are notes on C++17/C++20 changes as well. But those versions of the language are not covered by this book, but may well be covered by a future version.

There’s also a fantastic glossary at the end of the book, which weirdly I enjoyed reading, as I’ve heard many of these terms being an observer in BSi C++ Meetings, and now I’m starting to understand what they mean. And as is the form with the book, it’s an excellent glossary too! It’s around 60 pages or so! And it’s not just a quick sentence or two.

If I have one gripe, it’s that for such a big book, it feels flimsy. The pages are thin as is the cover. So it can be tricky to handle when you’re reading it. (Or it’s my own butterfingers…)

But in terms of content, I can’t fault it. The authors clearly know their stuff, and looking at the author list it’s a veritable who’s who in C++. The book is excellently written, and the topics expertly researched, and this is a book every C++ developer should have on their bookshelf.