Blog Archive for / 2023 /
Friday, 14 April 2023
The ACCU 2023 conference is next week, running from 19th-22nd April 2023, in Bristol, UK.
This year I will be presenting "Designing for concurrency using message passing" on 22nd April. The abstract is:
One common way to design concurrent code with less potential for synchronization and other concurrency errors is to use message passing. In this talk, I will walk through the design of some example code, showing how to build such a system in practice
This talk will include a brief description of what message passing frameworks are, and how they can help avoid concurrency errors.
I will then work through some examples, showing how the tasks are divided between the elements, and how the system can therefore utilise concurrency, while insulating the application code from the details of synchronization.
I have recently been through my bookshelves and found old books I don't want any more. If you want any of them, let me know, and I'll bring them along. These are all free to a good home:
- C++ Templates: The Complete Guide, First Edition by Daveed Vandevoorde and Nicolai Josuttis (Addison Wesley)
- The C++ Standard Library Extensions by Pete Becker (Addison Wesley)
- Modern C++ Design by Andrei Alexandrescu (Addison Wesley)
- C++ Primer 2nd edition by Stan Lippman (Addison Wesley)
- Learning XML by Erik T. Ray (O'Reilly)
- Unit Test Frameworks by Hamill (O'Reilly)
- Extreme Programming Adventures in C# by Ron Jeffries (Microsoft)
- Generative Programming by Czarnecki and Eisenecker (Addison Wesley)
- Find the Bug by Barr (Addison Wesley)
- DOS Programmer's Reference 3rd edition (MSDOS 5) by Dettman and Johnson (Que)
- Borland Turbo Assembler Quick Reference guide
- Oracle: The Complete Reference (for Oracle 7.3)
- Lloyds TSB Small business guide 2005
- Guide to Wave Division Multiplexing Technology
C++ Concurrency in Action, First Edition
I still have a small number of copies of the first edition of my book. If anyone wants these, I'll be selling them for £5 each. Let me know if you want one of these.
C++ Concurrency in Action, Second Edition
I'll also be bringing some copies of the second edition of my book. These will be for sale for £25 each. Let me know if you'd like one of these.
I look forward to seeing you there!
Review of Embracing Modern C++ Safely by John Lakos, Vittorio Romeo, Rostislav Khlebnikov and Alisdair Meredith
Wednesday, 01 March 2023
Verdict: Conditionally Recommended (3/5)
This is a huge book, over 1300 pages, and contains a wealth of information about all the language (not library) facilities added in C++11 and C++14. It has one "section" per language feature, and the sections are largely independent of each other, so they can be read in almost any order, and used as a reference. This is mostly a useful structuring, except for the few cases where there are closely related changes in both C++11 and C++14, and these are split into separate sections, that aren't even necessarily consecutive. Though there are already extensive cross-references between the chapters, the book would benefit from more cross references in such cases.
The word "section" is quoted above because they are what might be called "chapters" in other books. As it stands, the book has 4 "chapters", with "chapter 0" being the introduction, and the remaining 3 being what might be called "parts" in other books, and covering "Safe Features", "Conditionally Safe Features" and "Unsafe Features" respectively.
This use of the term "safe" is my biggest gripe with this book; much like a book on chainsaws might be titled "how to use chainsaws safely", the title makes the book seem as if it is going to be a tutorial on how to use modern C++ features without cutting your leg off. However, that is NOT the way that the authors use the word. They are using it with regard to "business risk" of adopting a specific language feature into a codebase that is mostly C++03 without providing explicit training to all the developers. Consequently the list of "safe features" is relatively small, and most features end up in the "conditionally safe" chapter, meaning that developers might need some training to use those features, rather than them being clear to developers only experienced with C++03. The authors explicitly call out that this "safety" axis is the one area where they intentionally deviate from their "Facts, Not Opinions" intent, and is the worst aspect of the book. As a general rule, developers should not be using language constructs they don't understand, so if a company wants to upgade to C++11/C++14 from C++03 then that company should provide appropriate training.
Consequently, I recommend that readers disregard the author's "safety" classification of the language features, and instead read the "Use Cases", "Potential Pitfalls" and "Annoyances" sections for each language feature and make up their own mind. It is particularly frustrating, since features that by and large make code clearer and less error-prone (such as lambdas, enum classes and range-for) end up being marked "conditionally safe" because they require training.
In the section on "Generalized PODs", the book covers what it means for objects to be "trivial", and be "trivially destructible", which are language constructs with specific meanings and consequences. They then go on to define their own term "notionally trivially destructible" to mean "those objects where the destructor has no code that affects program logic" (e.g. a destructor that only logs), and thus is safe to omit if you are directly controlling object lifetime (which should be a rare scenario anyway). This is not a language construct, and has no meaning to the compiler, but the similarity to the standard terms is too close and could easily lead to confusion. The inclusion of this in the book actually has the potential to decrease safety of a codebase, by encouraging developers to do things that might accidentally introduce undefined behaviour.
This book only covers the language features, not the library
features. Since a big part of the improvements from using C++11 and
C++14 comes from using the new library features (
std::auto_ptr, for example), this is a real let down, but given that
the book is already over 1300 pages, I can see why the authors decided
to leave it for another time.
Finally, this is a large, heavy book which makes it uncomfortable to hold it for any length of time, leading to contorted positions when reading. It is also a paper back book with very thin paper, so you can see print on the reverse side of the paper showing through, and a pale-grey font for comments in the example listings which is almost unreadable in many lighting conditions. This is particularly problematic, since many of the information in the examples comes from the descriptions of what each line means in the comment on that line. The e-book editions might thus be an improvement, though I haven't checked myself.
These gripes aside, there is a lot of useful information in this book. Each section covers a single language feature, how it differs from closely-related features in C++03, the precise details of syntax and use, intended use cases and potential pitfalls. If you want to know "how does this language feature work and what might go wrong", then reading the relevant section will give you a really useful set of information. You might still want to get training for the more complex features, but the sections actually contain enough information to get started, with copious examples.
In conclusion: this book is conditionally recommended. There is plenty of useful information there, but the presentation (both physically, and organizationally) is problematic.
Buy this book