The C++ programming language is successful. It has been popular for decades. It has been used in large, important systems. It has grown over the years, adding features that keep it competitive with other languages.
And it may be on its way out.
Other languages have challenged C++. Java was an early challenger, back in the 1990s. The latest challenger is Rust, and there is a good case for it. But I think the demise of C++ will not be caused by another language, but by the C++ language itself.
Or more specifically, changes to the language.
Consider a recent change to the C++ standard, to add variadic parameters to template functions.
I understand the need for variable -- excuse me, variadic -- parameters.
And I understand the desire by the C++ committee to minimize changes to the C++ syntax and grammar rules.
But code looks like this:
void dummy(auto&&...) {}
template<std::same_as<char> ...C>
void
expand(C...c)
{
std::tuple<C...> tpl(c...);
const char msg[] = { C(std::toupper(c))..., '\0' };
dummy(msg, c...);
}
This code is not easy to read. In fact, I find it a candidate for the long-ago obfuscation contest.
This enhancement is not alone. Most changes to the C++ specification, over the past two decades have made C++ harder to read. The result is that we have lost the readability of the original C, and the early C++ syntax. This is a problem.
While it was possible to write obscure and difficult-to-read C code (and C++ code), it wasn't inevitable. It was, with care, possible to write code that was readable. Not merely readable by those who knew C or C++, but by almost anyone familiar with a programming language or the concepts of programming. (Although the concept of pointers was necessary.)
The changes to the C++ standard have resulted in code that is, in a word, ugly. This ugliness now is inevitable -- one cannot avoid it.
Programmers dislike two types of programming languages: wordy (think COBOL) and ugly (what C++ is becoming).
(Programmers also dislike programming languages that use the ':=' operator. That may fall under the category of 'ugly'.)
The demise of C++ won't be due to some new language, or government dictates to use memory-safe programming languages, or problems in applications.
Instead, C++ will be abandoned because it will be considered "uncool". As the C++ standards committee adds new features, it maintains compatibility at the cost of increasing ugliness of code. It is a trade-off that has long-term costs. Those costs may result in the demise of C++.