Talk review: The Beauty and Power of “Primitive” C++

The Beauty and Power of “Primitive” C++ – Bjarne Stroustrup – CppCon 2020

The Beauty and Power of “Primitive” C++ – Bjarne Stroustrup – CppCon 2020

Review

This talk was given during the CppCon 2020 plenary session by Bjarne Stroustrup. Usually, we expect the father of C++ to give a speech that will stimulate our excitement for C++, explain upcoming features or give best practices for daily usage. Title suggested, that this year we would get something similar. In fact, I was 100% sure that the overall message will somehow relate to the massive attack of new language and library features in C++20 or the famous paper Remember the Vasa! This year Bjarne broke the pattern and did something completely different. The talk is in fact an overview of Bjarne’s personal project – the serialization library with minimalistic implementation. Author introduces us to his design goals and walks us step by step into the high-level modules of the library.

With all due respect, I was a little disappointed. Not about the quality of the talk, which was high as always. I simply expected something different. Currently, my time is very limited, so I must choose very wisely which talks I will watch to maximize the output value. This keynote didn’t give me any practical guidance which I should follow in my daily C++ practice. One may say, that I miss the big picture – the idea of “primitive” C++. I get that – Bjarne made it very clear that he wanted to present a fairly complicated problem in terms of only fundamental C++. It is important to remember, that we don’t need sophisticated third party libraries with lots of dependencies and complex implementation to handle tasks that arise. But this talk, as for me, was too much focused on library implementation rather than on methodology. Design choices were based on instincts rather than on production requirements – this is my perception. Nevertheless, it was interesting to see the thought process of Bjarne Stroustrup. The library is still in “work in progress” mode. I expect that many people will be interested in developing it, simply because of the author. Bjarne didn’t spoil his plans for the library – for now, this is only an experiment.

To sum up – this talk will not change your coding style or give you immediate guidance on modern C++. You will have a chance to see a different perspective on how to approach library design and how to value simplicity over extensive functionality.

In this talk you will learn

  • How to design libraries?
  • What to consider when creating generic API?
  • How to value simplicity over complexity?

Selected keynote slides

  • 1:25 – Problem: mapping typed objects to/from bytes for sending messages.
  • 1:49 – Constraints that should be taken into account.
  • 3:16 – There are lots of existing implementations and each is done in a different way (XML, JSON, protobuf…).
  • 4:26 – How to transport mechanism should be organized and separated from the business logic:
    • shared memory,
    • minimizing protocol overhead,
    • zero-copy policy,
    • flat structures,
    • simple data types and their compositions.
  • 7:27 – Message structure:
    • message descriptor – for serialization and deserialization,
    • span (Flat::Span<char>) used as default data abstraction.
  • 12:39 – Interface Definition Language.
    • IDL should be simple which will result in elegant code. Features can be added later when needed.
  • 15:51 – Overview of the framework architecture:
    • “When it comes to implementation, small is good.”,
    • “To be fast and correct, code has to be small and simple.”,
  • 17:54 – Small C++ library vs huge framework.
  • 25:18 – View is a proxy to the full message, that hides certain fields.
  • 26:09 – High-level tests that were performed.
  • 33:10 – String type definition.
  • 34:33 – Vector type definition.
  • 39:03 – Error handling:
    • interesting constexpr usage to define what should be done in a particular log level without the overhead of conditional branches.
  • 50:23 – Language observations while the library was developed.
  • 51:54 – Debugging observations.

Subscribe to get notified about new content

Thanks for taking your time to read it. If you like it or have other opinions, please share it in the comments. You can also subscribe to my newsletter to get latest news about my content. Happy coding and let’s stay connected!