Joseph Sibony
reading time:
I’m in Aurora Colorado, at CppCon 2021. It is so great to once again meet with the international C++ community in person! This Monday I gave my talk on C++ Complexity (you can find the slides here).
And much like I did at CoreCpp 2021, I asked the audience, using a survey: What’s complex in C++ for you?
This question is of course subjective, however few would argue that there is nothing complex in C++ (although this option was available in the survey).
The question of what makes C++ complex for you has important potential implications. We may deduce that:
- There are features that we need to teach better
- There are domains that may need improvements via the ISO process
- There are areas that may benefit from better tools
The survey had the same list of subjects as in CoreCpp, prepared after consulting with C++ community members, trying to cover all potential complexities. Here is the list that was presented – respondents could check any number of items:
- Nothing – everything in C++ is a breeze for me
- Pointers and references
- Memory and lifetime management
- Const correctness
- Rvalue and move semantics
- Constructors/Destructors
- Operators overloading
- Implicit conversions
- Multiple Inheritance
- Virtual inheritance
- Polymorphism
- Covariant return type
- Exceptions handling
- Lambda expressions
- Template specialization
- SFINAE
- Templates in general
- Smart pointers
- Multithreading and concurrency
- Lockless algorithms and memory fences
- Performance
- Testing
- Working with external libraries
- Following the new C++ standards
- Coroutines
- Compiling and/or linking
- Handling long build time
- Working with dynamic libraries
- Packaging and deployment
- Debugging memory leaks
- Debugging and troubleshooting crashes
- Debugging in general
- Specific GPU programming issues
- Specific Real-Time programming issues
In addition to the above options, there was also an option for “other”, asking the respondents to elaborate.
The questionnaire, presented both online and on-site, also asked for the respondents’ years of C++ experience, with the options: 0-1 years, 2-4 years, 5-8 years, 9-12 years, and more than 12 years.
The results are interesting.
Let’s start with the audience: years of experience in C++
Only one respondent added an “other” option, stating that “syntax is not intuitive even compared to C”. Well, expecting the syntax of C++ to be more intuitive than C is wishful thinking for a language that is much richer. Still, it is a valid concern.
One of the options in the list was ”Nothing – everything in C++ is a breeze for me”. It is interesting to note that no one in the entire sample of 74 respondents selected this option. This is compared to about 9% of respondents in CoreCpp that selected this option. CoreCpp was held locally this year, consisting of an Israeli audience, so we can deduce that Israelis tend to be more confident than others.
Here are the results for the complete sample, consisting of 74 people. You can quite see the categories, but you can understand the spread (for the raw results of our CppCon survey, scroll down):
The top five selections were:
- Rvalue and move semantics
- Debugging memory leaks
- Multithreading and concurrency
- Memory and lifetime management
- Following the new C++ standards
But when analyzing it based on seniority, veterans and novices suffer from different things.
For veterans the top five were:
- Handling long build time
- SFINAE
- Rvalue and move semantics
- Coroutines
- Following the new C++ standards
Top complexities – veterans:
For novices the top five were:
- Rvalue and move semantics
- Pointers and references
- Multithreading and concurrency
- Debugging memory leaks
- Memory and lifetime management
Top complexities – novices:
It is interesting to note that “Handling long build times” is in the top 5 for veterans, revealing that this is an issue that cannot be solved by experience alone. Of course, we at Incredibuild are happy to solve this issue for you, with distributed build acceleration already in use by many companies in the industry.
It is interesting to see that debugging memory leaks is still high in the list (35% of the entire sample – same percentage as in the CoreCpp survey) – long after smart pointers have become widely accepted in the industry. It is not clear if people do not use smart pointers, or otherwise misuse them. This should be further investigated.
Another interesting result is having Rvalue and move semantics at the top, not only for novices but also for veterans (55% in the entire sample and 42% for those with at least 12 years of experience). Seems that we do have some work cut out for us in teaching this subject better, making it easier to follow and understand.
Summary
The results at CppCon survey point in the same direction of those found in CoreCpp 2021. Some parts of the language that are perceived as complex and require better learning; other complexities may require better tooling. It is important to note that we presented in both posts the complexity of the language as perceived by those who attend a C++ conference. On the one hand, this doesn’t necessarily represent the entire population of C++ developers. On the other hand, it is quite clear that it does represent those who are more enthusiastic and involved with the C++ language, with its tweaks and rough edges.
Resources
Raw results of the CppCon survey on “What’s Complex in C++ for you?” together with the numbers of the above analysis, can be found here.
Table of Contents
Shorten your builds
Incredibuild empowers your teams to be productive and focus on innovating.