Content
Embracing Modern C++ Safely, authored by John Lakos, Vittorio Romeo, Rostislav Khlebnikov, and Alisdair Meredith, is a comprehensive volume exceeding 1300 pages, dedicated to the language features introduced in C++11 and C++14. The book is organized into sections that focus on individual language features, largely independent of one another, allowing readers to consult them in almost any order. This structure is mostly effective, though some closely related features from both C++11 and C++14 are split across separate, non-consecutive sections, which could benefit from enhanced cross-referencing for easier navigation.
The book is divided into four main chapters: an introductory chapter zero, and three parts labeled "Safe Features," "Conditionally Safe Features," and "Unsafe Features." However, the use of the term "safe" is somewhat problematic. The authors define safety not in terms of technical correctness or typical programming safety, but rather in terms of the business risk involved when adopting new language features in a codebase rooted in C++03 without comprehensive developer training. Consequently, only a small subset of features is classified as truly "safe," while many others are relegated to the "conditionally safe" category, implying the need for training to use them effectively. The reviewer considers this classification the weakest aspect of the book and recommends that readers disregard it. Instead, readers should focus on the sections covering "Use Cases," "Potential Pitfalls," and "Annoyances" to form their own judgments.
One notable discussion in the book concerns the concept of "Generalized PODs" (Plain Old Data types). The authors explain standard C++ definitions related to trivial and trivially destructible objects before introducing their own term, "notionally trivially destructible." This term describes objects whose destructors have no effect on program logic, such as those only used for logging. However, this concept is not part of the C++ language specification and carries a risk of confusion due to its similarity to established terminology. Moreover, adopting this notion could potentially lead to unsafe coding practices and undefined behavior, which contradicts the book’s aim of promoting safe usage.
The book exclusively covers language features and omits library features, which are an integral part of the enhancements offered by C++11 and C++14. For example, improved standard library components like std::unique_ptr versus std::auto_ptr are not explored here. While this omission is understandable given the book's considerable length, it represents a missed opportunity to provide a more complete picture of modern C++.
From a physical standpoint, the book's format presents some challenges. Its considerable size and weight make it uncomfortable to hold for extended periods, often forcing awkward reading postures. Additionally, the paperback uses very thin paper that allows text from the reverse side to show through, and the example code features comments in a pale-grey font that is difficult to read in many lighting conditions. These factors can detract from the reader’s experience, especially since the comments are essential for understanding the code samples. The e-book editions may alleviate some of these issues, although the reviewer did not confirm this.
Despite these criticisms, the book offers substantial value through detailed coverage of each language feature. Each section explains how the feature differs from its C++03 counterparts, provides exact syntax details, outlines intended use cases, and highlights potential pitfalls. This depth of information makes the book a useful resource for developers seeking to understand how modern C++ features work and what risks they might entail. While formal training is advised for more complex features, the book’s examples and explanations provide a solid foundation for getting started.
In summary, Embracing Modern C++ Safely is a conditionally recommended resource. It contains a wealth of valuable information but is hampered by organizational choices, the contentious "safety" terminology, and physical design considerations. Prospective readers should weigh these factors and consider supplementing their learning with training and additional materials, especially on library features, to gain a comprehensive understanding of modern C++.