I must admit that some previous years for C++ might feel a bit “boring” and “stable”. New features, new standard every three years, meetings, conferences… life as usual (apart from some additional World/Economy/public Health events…). This year seems different as it looks like a “breakpoint” in the history of C++… and who knows where it will lead us.
Let’s have a look at some things that happened this year.
Reports from previous years: 2021, 2020, 2019, 2018, 2017, 2016, 2015, 2014, 2013, 2012.
Disclaimer: the view presented here is mine, subjective, and does not represent the opinion of the ISO C++ committee or companies I work for.
A Brief Introduction
In 2022 the world tried to go back to “normal,” and regarding C++, this was visible through several “real”/live conferences and live ISO committee meetings. Compiler vendors are busy completing support for C++20 and even some C++23 elements. And the ISO committee works on the final parts of C++23 and some features for C++26.
Still, around the middle of the year, we started seeing some “cracks” as a few influential groups announced new programming languages. First, we have Val (led by David Abrahams), then Carbon (supported by Google), and then CppFront (led by Herb Sutter).
The next thing that looks curious is the improvements and the feedback loop we can see in the community. For example, Vittorio Romeo addressed a long-standing debugging performance issue for std::move
, std::forward
, and some other small routines. The positive thing is that vendors relatively quickly implemented those suggestions.
Overall, I see the following major trends and topics in 2022:
- C++23 feature freeze
- C++20 adoption
- New languages
- Feedback loop and better tools
What’s more, we can add another point: ChatGPT Announcement. While it’s not strictly related to C++, it can hugely impact how we write programs, learn and even teach. In short, ChatGPT proved that it can be a handy assistant for various tasks, so we’ll see
Read on to get the complete picture.
Timeline
To set a background, let’s see the main events that happened:
Date | Event |
---|---|
7 February | ISO C++ Committee meeting Zoom plenary |
15 February | Visual Studio 2022 17.1 |
25 March | Clang14.0 |
6 April | ACCU, till 9th April |
13 April 2022 | Boost 1.79: Major release now available |
2 May | Val Announced at Cpp Now |
6 May | GCC 12.1 |
10 May | MSVC’s STL Completes /std:c++20 (for the second time :) |
22 July | Carbon announced at C++North |
25 July | ISO C++ Committee meeting Zoom plenary, C++23 is frozen now |
9 August | Visual Studio 2022 17.3 |
19 August | GCC 12.2 |
6 September | Clang 15.0 |
11 September | CppCon, till 16th Sept |
16 September | CppFront announced at CppCon |
7 November | ISO C++ Committee meeting - Kona Hybrid, till 12th Nov |
8 November | Visual Studio 2022 17.4 |
16 November | Meeting C++, till 19th Nov |
30 November 2022 | Chat GTP Announced |
14 December | Boost 1.81: Major release now available |
22 December | libstdc++: Implement C++20 time zone support in <chrono> |
Here’s a video summary of this table:
Compiler Support for C++17
I don’t want to be boring this time. All major compilers support C++17… there are only a few exceptions, like missing floating point support for from_chars
, to_chars
, or issues with parallel algorithms.
Please note that since GCC 11, you get C++17 compilation mode by default, see this article. As of Clang 16 you’ll also get gnu++17
by default, see this article
If you want to learn all features of C++17, here’s my overview:
Compiler Support For C++20
It’s the end of 2022, and only MSVC (VS 2022 17.0) has complete support for the Standard. GCC 13.0 (almost released) has the most features, while Clang (16.0) is slightly behind. The main features lacking or “problematic” are modules, std::format
, std::chrono
additions, and coroutines. But we’re slowly getting there.
Here are some of the best features added to the Standard:
- Modules
- Coroutines
- Concepts and Concepts in the Standard Library
- Ranges
- operator
<=>
and its use in the Standard Library, simplified operator rewriting rules - Text formatting -
std::format
- Calendar and timezones
jthread
, semaphores, more atomics, barriers, and more concurrency stuffconsteval
andconstinit
constexpr
algorithms, vector, string, memory allocationsstd::span
- and more!
And here’s the table with compiler notes for language features:
Compiler | missing features/notes |
---|---|
GCC 11 | Only Modules are in the “partial” state |
Clang 14/16 | Modules in partial, coroutines in partial, CTAD improvements missing |
MSVC 16.9 | Full support! |
Regarding library features:
Compiler | Notes |
---|---|
GCC libstdc++, GCC 13 | almost all support! |
Clang libc++, as of Clang 14 | missing: jthread , Standard library header units, make_unique_for_overwrite , some atomics missing, |
MSVC STL | Full support as of MSVC 16.9, 17.0! |
You can track the status @cppreference - C++20 support.
If you want to learn all features, you can see this great and super popular blog post by Oleksandr Koval:
All C++20 core language features with examples
This year at C++ Stories, I also covered a lot of features from the new standard:
The C++23 Status
This year was notable for the new Standard as it got into “feature freeze” mode. The committee announced this stage mid-year, after the June ISO meeting.
Some language features and their current support in compilers:
Feature | GCC | Clang | MSVC |
---|---|---|---|
Make () more optional for lambdas |
11.0 | 13.0 | x |
if consteval |
12.0 | 14.0 | x |
Deducing this |
x | x | VS 2022 17.2 (partial) |
Multidimensional subscript operator | 12.0 | x | x |
#elifdef and #elifndef |
12.0 | 13.0 | x |
static operator() |
13.0 | 16.0 | x |
static operator[] |
13.0 | 16.0 | x |
Support for UTF-8 as a portable source file encoding | 13.0 | 15.0 | VS 2015 |
And one of the most exciting things that were added and also went viral was the addition of P2718R0 which is a refinement for P2012 “Fix the range‐based for loop”.
In short, you’ll be able to write:
std::vector<std::string> createStrings();
for (char c : createStrings().at(0)) // <<!
{
// some code...
}
As of C++20, the above for-loop statement has UB because we access a temporary object whose lifetime has ended. In C++23, all temporary objects in that loop expression will extend their lifetime, not just the first one.
And library:
Feature | GCC | Clang | MSVC |
---|---|---|---|
Stacktrace library | x | x | x |
std::is_scoped_enum |
11.0 | 12.0 | VS 2022 17.0 |
contains() for strings and string views |
11.0 | 12.0 | VS 2022 17.0 |
constexpr for std::optional and std::variant |
12.0 | 13.0 | VS 2022 17.1 |
std::out_ptr(), std::inout_ptr() |
x | x | VS 2022 17.0 |
ranges::starts_with() and ranges::ends_with() |
x | x | VS 2022 17.1 |
DR: std::format() improvements |
13.0 | 16.0 | VS 2022 17.2 |
ranges zip | 13.0 | 15.0 | VS 2022 17.3 |
Monadic operations for std::optional |
12.0 | 14.0 | VS 2022 17.2 |
<expected> |
12.0 | 16.0 | VS 2022 17.3 |
ranges::to |
x | x | VS 2022 17.4 |
Pipe support for user-defined range adaptors | x | x | VS 2022 17.4 |
ranges::iota() , ranges::shift_*() |
x | x | VS 2022 17.4 |
views::join_with |
13.0 | x | VS 2022 17.4 |
views::chunk_* and views::slide |
13.0 | x | VS 2022 17.3 |
views::chunk_by |
13.0 | x | VS 2022 17.3 |
<flat_map> , <flat_set> |
x | x | x |
Formatted output library <print> |
x | x | x |
Formatting ranges | x | x | x |
constexpr for integral overloads of std::to_chars() and std::from_chars() |
13.0 | 16.0 | VS 2022 17.4 |
Standard Library Modules | x | x | VS 2022 17.5* |
Monadic operations for std::expected |
x | x | x |
ISO C++ Meetings
This year we had three ISO meetings:
- Two virtual, single-day, plenary voting: in February and in June.
- One hybrid in Kona, Hawaii! Going back to normal :)
The plan is to complete the draft on C++23, fix issues reported by National Bodies, and then send it to the publication in the Spring of next year. We can expect C++23 to be officially announced around Autumn 2023.
Here are some notes from the meeting:
The next meeting will be held in Issaquah, WA, USA, starting from 6th February.
See the complete list of meetings: Upcoming Meetings, Past Meetings : Standard C++
Compilers
Compiler vendors and library teams have a lot of work to catch up with the C++ standards.
Let’s look at three major compilers: MSVC, GCC, and Clang.
Visual Studio
The MSVC team has rewritten their compiler infrastructure, and they can relatively quickly push new features. They even announced the C++20 support twice!
MSVC’s STL Completes /std:c++20 - C++ Team Blog
This announcement was mainly due to some additional changes and DR Standard fixes for <format>
, <chrono>
, and <ranges>
. Once they were completed, the implementation is now stable again.
Some other MSVC news and blogs articles:
And here’s a documentation page about the conformance with C++ Standards (including C++20): Microsoft C++ language conformance table
Additionally, you can track the progress of the Standard Library implementation on Github: Changelog · Microsoft/STL Wiki.
GCC
Current stable version GCC 12.2 from August GCC 12 Release Series.
You can also see the preview of the upcoming GCC 13: GCC 13 Release Series — Changes, New Features, and Fixes - GNU Project.
Language and the Library support notes:
And some news about GCC:
Clang
Current stable version: 15.0.6 from late November, Welcome to Clang’s documentation! — Clang 15.0.0 documentation.
And also, you can preview Clang 16: Clang 16.0.0git (In-Progress) Release Notes — Clang 16.0.0git documentation.
Debugging performance
Let’s expand the topic on performance and the feedback loops:
Here’s the article by Vitorio Romeo: the sad state of debug performance in c++ - and fixed in Improving the State of Debug Performance in C++ - C++ Team Blog
In short, thanks to the msvc::intrinsic
attribute, the team managed to annotate a couple of move-related functions, and in some cases, the code generation yields 226 instructions in 17.4 while 17.5 gives only 106! From release notes: std::move
, std::forward
, std::move_if_noexcept
, and std::forward_like
will now not produce function calls in generated code, even in debug mode. This is to avoid named casts causing unnecessary overhead in debug builds. /permissive-
or a flag that implies it (e.g. /std:c++20
or std:c++latest
) is required.
Additionally, we have two bugs reported by Vittorio: 104719 – Use of `std::move` in libstdc++ leads to worsened debug performance and Use of `std::move` in libc++ leads to worsened debug performance · Issue #53689 · llvm/llvm-project - they seems to be fixed in GCC and Clang, and they can now fold simple instructions.
Overall, there’s a lot to do on the debugging side of C++, but as you can see, the community works well, tries to listen to the needs, and vendors improve their implementations.
C++ successor languages & Security
The ISO C++ process may be slow in some cases and inefficient. Plus, there are lots of “holy” wars in the committee, especially about things like “no breaking ABI”. In some cases, we know several issues in the Standard, and we know how to fix them… but because we cannot break ABI, nothing can be done (apart from adding some hacky workaround). Some groups, for example, from the Google team, were a bit discouraged by this fact and created some new approaches to C++.
There’s a great article: The Year of C++ Successor Languages By Lucian Radu Teodorescu, where you can read about approaches and short descriptions for each language.
In the article, we can read that despite being criticized (a lot!), C++ has consistently been in the top 4 programming languages for the past 30 years. Critics argue that the language is too large and complex, with features that should be removed and with too many and not enough features at the same time. These criticisms have led to the creation of several programming languages that aim to succeed C++ as the dominant system programming language. In 2022, three languages were announced at major C++ conferences: Val, Carbon, and CppFront. This article provides a critical perspective on these languages and their potential as C++ successors.
Val
Announced and led by Dave Abrahams and Dimitri Racordon, heavily influenced by Swift, seems coherent and easy to use.
Carbon
Backed by Google (and, according to Chandler, also by Adobe), “feels like a C++ cleanup project.”
and more links:
CppFront/Cpp2
Led by Herb Sutter, is an attempt to have a better syntax and better defaults… but still compile to C++.
My view
It’s always good to have competition. C++ might benefit from other languages and exchange features from Carbon or Rust.
What’s more Security “theme” seems to be visible this year, and we have reports like:
ChatGPT
I asked the bot, but it didn’t tell me if it was written in C++. I guess some parts could be done in C++, but since it’s a vast system, many technologies might be used there.
In a C++Weekly video: C++ Weekly - Ep 354 - Can AI And ChatGPT Replace C++ Programmers? - YouTube, Jason Turner experiments with the bot. Sometimes, it creates valid responses, but you still have to pay attention to details. This chatbot can be a really helpful coding assistant.
I also read an excellent email from Fahim ul Haq founder of Educative:
AI like ChatGPT will change the landscape of software development — but not in the way that many fear. As a software engineer and developer learning advocate, I believe ChatGPT can help us make better software, but it can’t replace developer jobs.
Fahim also suggests the following ideas about the chatbot:
“ChatGPT is going to make coding more productive and bug-free. As it accommodates more complex requirements, we can look forward to it helping eliminate grunt work and accelerate productivity and testing. "
As assistants such as ChatGPT evolve, many of the tedious tasks that have occupied developers could go away in the next decade, including: automating unit tests, generating test cases based on parameters, analyzing code to suggest security best practices, and automating QA .
Not to mention the learning and teaching capabilities. Imagine a friendly “tutor bot for C++”. You can learn a programming language or ask about any language feature just like you ask your expert colleague at work.
I think we’ll see lots of inspiring tools in the next year…. maybe even something strictly for C++; who knows :)
Conferences & Online Events
Look at this link to ISO C++ page with all registered conferences worldwide: Conferences Worldwide, C++FAQ.
Some highlights, resources, and keynote videos:
Meeting C++ Online
I’m impressed with Jens Weller, who created a global online meetup:
Meeting C++ online (Düsseldorf, Deutschland) | Meetup
For example, have a look at some recent AMAs:
Books
A few selected books that arrived in 2022 (or late 2021):
Disclaimer: Links in the table are affiliate links to Amazon.
See my review of “Embracing Modern C++”: Embracing Modern C++ Safely, Book Review - C++ Stories
And there’s also my book: “C++ Initialization Story”, released in mid 2022 and completed in December:
C++ Initialization Story @Leanpub
Get C++ Initialization Story only for 9.99$ (not 15.99$), only till 1st January
Popularity
C++ seems to have stable growth in various programming languages’ “popularity” charts this year.
Have a look:
The image is based on data from Stack Overflow survey and Tiobe Index.
According to Github, Octoverse C++ is in 6th position (last year it was in the 7th place); see here.
What’s more, there was also an interesting article from early November: The pool of talented C++ developers is running dry
From the article:
Anthony Peacock, formerly a quant at both Citi and Citadel said “it’s impossible to find people with a really high level of C++ skills, which is exactly what every trading company wants.”
Even if Carbon, Rust or CppFront is just around the corner… (or not)… there will be still a ton of C++ code to maintain. What’s more, lots of areas like finance will still use C++ for their low-level infrastructure.
Here’s the related discussion at Reddit: The pool of talented C++ developers is running dry : cpp with over 350 comments!
Your Input & Survey
On 12th December, I started my annual survey about the use of C++ in the last year. I got 649 votes. Thank you!
Let’s make some summaries and tables from your answers :)
C++ Standard Used
On a daily basis, which C++ Standard do you use?
Answer | 2022 | 2021 | 2020 | 2019 | 2018 |
---|---|---|---|---|---|
Pre C++11 | 10.8% | 7.5% | 8.4% | 10.3% | 20% |
C++11 | 27.6% | 25.6% | 25.5% | 30.3% | 41% |
C++14 | 28.7% | 28% | 28.6% | 35% | 42% |
C++17 | 61.8% | 66.1% | 64.4% | 62.4% | 44% |
C++20 | 42.2% | 28.8% | 20.4% | 9.2% | n/a |
(The numbers for the above do not sum to 100%)
C++20 gets much more uses, while C++11/14 stabilizes at around 28%.
Experience with C++17
What’s your experience with C++17?
Answer | 2022 | 2021 | 2020 | 2019 |
---|---|---|---|---|
experimenting with C++17 | 29.7% | 28.9% | 34.9% | 39.4% |
only read basic information | 10.2% | 11.4% | 9.4% | 13.4% |
already using in production | 57.6% | 56.6% | 52.2% | 41.6% |
don’t know any of its feature | 1.8% | <1% | 1.6% | 2.6% |
Experience with C++20
What’s your experience with C++20?
Answer | 2022 | 2021 | 2020 | 2019 |
---|---|---|---|---|
experimenting with C++20 | 37.8% | 35.7% | 35.6% | 29.3% |
only read basic information | 36.2% | 44.1% | 50.8% | 59.8% |
already using in production | 17.6% | 12.8% | 6.8% | n/a |
don’t know any of its feature | 7.7% | 6% | 5.2% | 9.1% |
Compilers Used
What compiler do you use?
Answer | 2022 | 2021 | 2020 | 2019 |
---|---|---|---|---|
GCC | 70.9% | 76% | 70.3% | 75.6% |
Clang | 46.1% | 51.8% | 49.6% | 58.7% |
MSVC | 54.7% | 54.1% | 58.5% | 56.3% |
Intel Compiler | 2.5% | 2.3% | 2.8% | 3.1% |
C++ Builder | 1.1% | 2.2% | 3% | 1.2% |
(The numbers for the above do not sum to 100%)
What IDE do you use for C++ projects
Answer | 2022 | 2021 |
---|---|---|
Visual Studio | 48.2% | 48.8% |
Visual Studio Code | 49.3% | 47.1% |
CLion | 19.3% | 18.5% |
C++ Builder IDE | 1.5% | 2% |
Eclipse | 6.2% | 5.8% |
Vim/Emacs | 24% | 26.9% |
QT Creator | 14.6% | 15.7% |
Notepad++ | 9.1% | 7.4% |
XCode | 6.8% | 6.1% |
Answer | 2022 | 2021 | 2020 | 2019 |
---|---|---|---|---|
Debugger | 74.3% | 80.8% | 77% | 83.6% |
Sanitizers | 36.8% | 38.9% | 31.9% | 40.4% |
Static Code Analysis | 57.2% | 58.7% | 60.9% | 55.7% |
Profilers | 43% | 49.1% | 53.4% | 56.8% |
Clang Format | 45% | 49.4% | 43.3% | 49.3% |
CMake | 64.9% | 67.3% | 62.3% | 66% |
Package Managers | 25.3% | 26.2% | 23.2% | 21.4% |
(The numbers for the above do not sum to 100%)
Best thing that happened in 2022:
Answers from this open question, based on popularity (I tried to group similar things), no special order:
- C++ language updates and standards: You mentioned updates to the C++ language, such as the release of C++20 and C++23, as well as the adoption of new features and proposals.
- New languages: Carbon / Cpp2 / Val, and triggering the discussion on the next steps in the community.
- Conferences and events: as usual, conferences such as CppCon and Meeting C++ got many votes.
- Books and resources: “A Tour of C++”, “Embracing Modern C++ Safely,” and “Klaus Iglberger’s book on Software Design” were quite popular among the answers.
- YouTube channels: especially Jason’s Turner, Cppcon Channel YouTube, or Meeting C++ Youtube
- Personal projects and learning: Many of you mentioned working on personal projects or learning more about C++ to improve your skills and understanding of the language.
- Compiler support: the availability of compiler support for new C++ standards as an essential development in the C++ community.
- C++’s popularity: responses mentioned TIOBE and other rankings
Additionally, it’s great to hear such news like
- “Move in my company to C++20”
- “personal upgrade from c++14 to c++20”
- “I just got a job in C++ again and I’m quite happy with it”
Or: “We are still alive ;-)” :)
There were also many positive opinions about the blog, my books and the newsletter! Thank you!
I’m getting to enjoy your C++ Initialization book
I found your c++ stories blog. It was quite useful for my interview preparations
Other surveys:
My survey is not the most important :) Have a look at other larger surveys run by those companies:
Summary
Thanks for reading up to this moment :)
C++ is at a crossroads today: on one side, it’s in really good shape, with lots of new features, compiler support, and cool tools (even better-debugging performance!). But at the same time, many experts struggle to make language inherently safer and fix some long-standing issues ( breaking ABI discussion). That’s why some experts try to start from something fresh and improve C++ by creating a new competition. Those new languages directly compile to C++ (as CppFront), or have robust interoperability with C++ (like Carbon). So maybe in the future, you’ll be writing in a super safe C++2 language and still have some legacy files in good old modern C++ in the same projects. I hope “friendly competition” will push C++ to new directories and get us better features and safer code.
What’s more ChatGPT merges, so who know if we’ll still be coding next year :)
To summarize, my big things for 2022:
- C++20 adoption
- C++23 ongoing
- New languages and new opportunities to push C++ further
- Community discussions and feedback loops
Best wishes!
Promos:
Your Turn
- What do you think about C++ in 2022?
- What was the most crucial event/news for you?
- Did I miss something?
Join the discussion below the article.
from Hacker News https://ift.tt/f4zCtyl
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.