The last edition of the CppCon 2017 just ended. As for the previous edition, it was a real pleasure to be there, discussing with talented and curious fellow developers, and watching great talks. In particular, I got the feel that the conference offered more diverse talks than the previous edition.
Inspired by the trip report of Ben Deane, this post is there to share with you the talks I found especially worth watching. I tried to group the talks in 3 general topics, and illustrate each of these topic with 3 good talks:
- Three talks that revisit things what we take for granted
- Three talks that explore uncharted territories of C++
- Three talks that delivers great technical pieces of advice
Finally, to round up to 10, I added a bonus talk, a favorite of mine, at the end.
Note: a lot of the videos are not yet online. The links provided in this posts point to the CppCon 2017 schedule. The link to the youtube videos will be added to the post as they become available.
Talks revisiting things that we take for granted
This edition of the Cpp Con contained a fair bit of talks providing another point of view on the kind of things we take for granted. This talks were great, for their ability to make us re-think our basic assumptions about software, and identify things we could improve upon as individuals and as a community.
Titus Winters – C++ as a “Live at Head” language
In this talk, Titus provides some insights on how to approach the problem of maintaining C++ software over time, and making it adaptable over time, which is a fundamentally different problem than just producing a piece of software that works today (as he calls it, software engineering versus programming).
He revisits some of the things that we take for granted, such as the Semantic Versioning, the Argument Dependent Lookup (ADL), or the systematic focus on zero cost abstractions, and explain in which way they end up decreasing our ability to live at head.
This felt controversial for many attendees. But I think it is worth distinguishing the problem from the solution proposed by Google. And although you might disagree with the solution, I think the problems identified in this talk are definitively there and this is what makes this keynote really worth watching.
Note: I also recommend looking at the follow up talks, in particular the talk from Jon Cohen, named a type by any other name which illustrates in more details the content of the keynote of Titus.
Peter Sommerlad – Mocking frameworks considered harmful
This talk by Peter Sommerlad is a pretty interesting view on the disadvantages of using Mocks and the deficiencies of the usual Mocking frameworks in C++.
He first discusses how overusing Mocks ends up destroying the design, makes Unit Tests verbose and hard to factorize, and undermines the purpose of Unit Tests by making them fragile (due to over-specification and coupling to the implementation details of the system under test).
He then discusses some of the specific problems of typical Mocking frameworks used in C++, namely the typical implementations based on macros, their Domain Specific Language (DSL) forced upon the user, and their implementation based on expectations checked using RAII (checked at the moment the test ends).
His overall advice? Try not using Mocks but for existing legacy code.
Louis Dionne – Runtime polymorphism: back to the basics
In this talk, Louis Dionne deconstructs runtime polymorphism in C++. He talks about the various problems interfaces causes in C++ (like the loss of value semantic, the null-able semantic, or their intrusive nature) and explores alternate designs and their associated trade-offs, based on his dyno open-source library.
This talk is a really good example of how we can revisit some of things and mechanics that we take for granted, deconstruct them, select a different set of constraints, and find different ways to implement them.
It is also a great lesson in terms of separation of concerns. In particular, I really liked how Louis Dionne manages to separate the storage policy from the definition of classes, and ends up using dyno to factorize the implementation of std::function and std::function_ref in one single class.
A very valuable watch for anyone interested in design and asking the right questions.
Talks exploring uncharted territories
Some talks focused on exploring uncharted territory in terms of C++ features or C++ idioms. These talks are especially valuable for their ability to make us envision the future.
Herb Sutter – Meta: Thoughts on generative C++
In this keynote, Herb Sutter talks about the rationale behind meta-classes for C++, the on-going status of the proposal, along with the status of the pre-requisites (constexpr algorithms, containers, and constexpr blocks) and the challenges it involves (like supporting debugging facilities).
It is a great watch, with a live-demo of meta-classes inside the compiler explorer:
I enjoyed especially the rationale behind this proposal.
We should not be afraid of the power of meta-classes (and the fact that they really feel like Lisp) because C++ developers already implement manually the things that meta-classes allows us to do. But we do it using more complex mechanisms such as template meta-programming or CRTP.
And the very fact that C++ developers already do these things even though they are painful to do shows us how valuable it is to invest in this direction.
Andrew Sutton – Language support for compile-time reflection
In this talk, Andrew gives an overview of what compile time reflection is and is for, talks about the different ways we could implement it in C++ (type-based or value-based), explains the choices that motivate a value-based approach, and describes how he implemented it in Clang.
Watching this talk, you will learn in more details what is reflection – namely the ability to see source code as data we can manipulate – what are projections – the reverse ability to produce code from reflected values – and some of the design choices behind the current proposal:
- Why runtime reflection is not the option retained for C++ (for performance reasons, because the comity is not interested in programs modifying themselves at runtime, etc.)
- Why type-based reflection, although more easily accessible, is not a good option (instantiating types is expensive as compilers never forgets a type and it grows memory, etc.)
An interesting look into the future of C++.
Odin Holmes – Agent based class design
In this presentation, Odin Holmes decribes his alternative to Policy Based Design, which he calls Agent-based design. The goal is to offer a way to build classes out of simple building blocks – agents – which can interact between them through their capabilities and be aggregated into higher level agents.
- He underlines some of the deficiencies of Policy Based Design
- He illustrates by example good programming principles (*)
- He builds on these motivations to explore a potential design, agents
Now, and despite the humor of Odin (I really much enjoyed the unicorn call syntax), this is not an easy talk. I wished there was a way to pause the presentation while it was being given. Enjoyable, interesting, but also quite challenging: you have been warned.
(*) Like building composable abstractions which do not require building a tower of layers, a bit like Monoids which we covered in a preceding article, by combining agents into agents.
Great technical presentations
The last category of talk is focused on delivering great technical pieces of advice for C++ developers to improve the implementation and the design of their code.
Stephen Dewhurst – Modern C++ interfaces
In this presentation, Stephen starts by explaining that the more complex the language, the more idioms and conventions we need to write simple and API in this language. Our goal should not be to write code in C++ directly, so much as writing code in terms of a small and orthogonal basis of idioms built over C++.
He then explains and illustrates how leveraging SFINAE to communicate between types and algorithms is one such idiom that helped the C++ developers to build simpler and much smarter API over the past few years, despite the increase of complexity of the language itself.
Stephen also defends the idea that while semantic and idioms are important, syntax is also very important, since it is the medium by which we can encode the semantic and these idioms in our language. And to illustrate this, he builds an API to expressively encode complex expectations on types and make SFINAE practical (Hello, constexpr Abstract Syntax Tree of constexpr predicates on types).
This was one of the first talk of the conference, and it is an absolutely great one. Watch it.
Vinnie Falco – Make classes great again!
The talk starts by describing the naive implementation of the Request and Response types for an HTTP server, and then goes into interesting tricks and techniques to improve these types definition by factorizing them and making them extensible in terms of feature and storage policy.
Vinnie also provides us with valuable tips and techniques we can use to document our expectations in terms of template parameters, from SFINAE, to examplars (class definition that comply with the concepts) and more formal forms of documentation.
These were valuable tips that are always worth taking from a Boost author.
Sergey Ignatchenko – Eight Ways to Handle Non-blocking Returns
In this presentation, the author of ithare.com covers several ways to handle non-blocking return in a message passing architecture, from the ones already available in C++98 up to the new kind of design which will become available in the coming C++20.
This is a very good presentation, which starts with a summary of the principle behind message passing, “do not communicate by sharing, share by communicating“, and goes into great depth in comparing the trade-offs of the different ways we can implement message passing in C++.
You will learn about patterns such as lambda pyramids, future continuation chains, code builders, or co-routines. You will also learn about some specific challenges of message passing implementation techniques, such as the ability to serialize the state of a reactor (the state machine handling messages).
This talk is full of interesting things to learn, and pointers to techniques you might not have heard of.
Now, I must admit that I could not finish listening for Matt till the end. When he announced the support of Haskell in the compiler explorer, I was so thrilled that I reached for my tablet and played with this new toy to code something like this (despite the pain of coding on a tablet).
Now, there is still a lot that could be done to improve the ASM output of Haskell (some filtering mainly), or dump the GHC core representation, but this is great that such a tool now exists.
Thank you Matt Godbolt for this Haskell godbolt!