r/cpp • u/SubstanceHot5190 • Jun 25 '26
What are some things you don't like about C++?
I asked this question in the C programming sub too.
What are some things you don't like about C++
If you were to change some things about C++, add keywords, or other similar things,
what would you change? Replace? Add?
My most important question is about keywords. What keyword would you add ( even just describing its functionality) to help YOU as a programmer?
Thank you :)
74
Upvotes
169
u/Frosty_Maple_Syrup Jun 25 '26
I wish std::print was included in the language long ago, I wish the standards committee would pick a package manager to be the official one, I wish modules were in the language from the beginning and I wished that all the compilers would actually support the latest features when they came out and not years later (or in the case of modules seemingly never).
80
u/EvenPainting9470 Jun 25 '26
Build system, cryptic errors, bad defaults, people
53
u/tstanisl Jun 25 '26
The syntax and mechanics of initialization is a total mess.
20
u/notforcing Jun 25 '26 edited Jun 25 '26
(1) Lack of support for basic types, like bigint and bigdec. No int128_t or uint128_t, presumably because of std::intmax_t and std::uintmax_t. No float128. This inhibits the development of libraries that require support for such types, including CBOR and BSON parsers.
(2) We have chrono but no simple standard datetime
(3) Lack of a good regex library in the standard library. regex is ubiquitous. The lack of a good standard one holds back the C++ ecosystem.
(4) the bool specialization of
std::vector(5) That fact that
std::pmr::polymorphic_allocatorhas a default constructor(6) That
std::map's operator[] is a mutating accessor(7) Lack of consistency, part 1
std::string s = "Hello world";const char* cs = s.c_str(); // no implicit conversionstd::string s1 = cs; // implicit conversion okstd::string_view sv = s; // implicit conversion okstd::string s2 = std::string(sv); // no implicit conversion(8) Lack of consitency, part 2(9) C++ promises generics and custom allocation, but the library itself defeats that in many ways. Why all those
to_string,to_wstringetc. functions, why not a generic one that allows the programmer to provide an allocator? Why so many functions that allocate, e.g.stable_sort, that have no way to provide an allocator? Why no requirement forstd::hashfor strings with user supplied allocators?(10) The fact that output iterators don't require a value_type in
std::iterator_traits, which is an irritating inconsistency that makes writing generic code harder.(11)There doesn't appear to be a general way to detect at compile time whether an allocator propagates to nested containers, calls to emplace functions need to know that.(12) Lack of unicode support.
(13) That fancy new things like ranges get attention while basic fundamental things languish.
I'll stop here.
36
u/thoosequa Jun 25 '26 edited Jun 25 '26
A portable and usable cross platform way of managing dependencies and building binaries, is the obvious mention.
A smaller thing that comes to mind is a reverse operation for std::format that, rather than printing a string, I want to read from a string and populate arguments. There was a proposal for such a thing, I believe it was std::scan but I don't recall exactly.
I don't do a lot of parsing strings, but when I do it almost always sucks.
47
u/_Ilobilo_ Jun 25 '26
companies sticking to old versions and not updating
13
u/moreVCAs Jun 25 '26
implicit casts
11
u/ContraryConman Jun 25 '26
The first full day of setting up any new C++ project for me is actually setting up CMake + vcpkg + gtest + clang-tidy + intellisense. I wanted to challenge myself to use modules and
import stdfor this project, which made it even more complicated. I know that the equivalent setup in Rust is one command. That sort of sucks11
u/ConceptJunkie Jun 25 '26
std::chrono is way too hard to use. I understand how complicated time is. I've written a tool in Python deals with time and calendars, etc., and understand the complexities of deal with time. In Python, simple time things are easy. Complicated time things might be hard, but that's common. I've used a couple different Python time libraries (arrow and pendulum), and each has strengths and weaknesses.
In C++ with std::chrono, hard things are hard, and simple things are also hard. I had to rely on cookbooks to do simple things like parse time strings.
Maybe my opinion would change if I worked with it more. My experience with std::chrono was about 6 years ago.
10
u/ronchaine Embedded/Middleware/WG21 Jun 25 '26
Implicit conversions and
const &&.10
u/Jason5Lee Jun 25 '26
The price of learning the right way to do things.
It cost me actual money. C++ is the only language I paid for a course to learn—one that claimed to actually teach you how to think in C++ and use its features to solve specific problems. The course did a great job; I'm just frustrated by the fact that I needed a paid course. For every other language I've learned, whether difficult or easy, I may have found it hard, but never felt *missing*. I could just follow the official documentation and ask questions (there was no AI back then). For learning C++, that was apparently not enough.
9
u/franvb Jun 25 '26
Trying to help beginners set up is still challenging.
9
u/Prestigious_Water336 Jun 25 '26
I'd like to see a keyword called "complete" that completes your project for you and reads your mind
8
u/levir Jun 25 '26
I long for a per compile unit "version 2" declaration that would remove old cruft and footguns from the language, and make it safer. A lot of decisions were made long ago that no longer applies, and I wish I could program C++ with a safe by default approach without losing the great things about the language (like RAII).
8
u/TheJesbus Jun 25 '26
void not being a 'real' type
References being part of the type system
8
u/Trucoto Jun 25 '26
No sane build system (make and cmake are really a mess)
No standard package manager.
No standard programming style.
Those are three things that Rust made right.
7
u/umlcat Jun 25 '26
The cin / cout stream classses I would add some functions with identifiers that do the same as the "<<" and ">>" operators and leave them as part of the C++ standard library.
7
u/SayuriShoji Jun 25 '26
Replacing auto with
funcorfunctionfor functions with trailing return type:func DoSomething(int x, int y) -> int;I think having a distinct keyword for functions could make parsing code much easier and is easier to read.
Also, named parameters for functions. It would be nice to be able to call functions with named parameters. This would be especially useful for functions with LOTS of default parameters:
void DoSomething(int x, int y = 123, int z = 456, int q = 999)What if I only want to customize q for a call? This should be made possible:
DoSomething(3, q = 888);The compiler could easily figure out that y and z should be used with their default values and insert those automatically. Yes, we can use structs to pack the function parameters, but that's beside the point. It should be possible without manually having to create arg structs.
7
u/lonkamikaze Jun 25 '26
thisshould be a reference7
u/James20k P2005R0 Jun 25 '26
The way that integral types and arithmetic works in C++ is bonkers. The "usual arithmetic conversion" system is pretty nuts, and makes using types smaller than
inta minefieldThe platform dependence of the size of
intand the other basic types doesn't seem to have worked out as planned either. The nice idea was that if everyone wrote their code bearing in mind the standards compliant ranges of int (ie 2 bytes) etc, we'd have portable codeIn practice on desktop everyone assumes that
intis 4 bytes big, which is a problem because it absolutely isn't on some platforms, which hinders portability. It'd be better ifintwas simply an alias forint32_tThe other end of this with conversions is that integral literal's being typed often leads to very convoluted code. Eg if you write this:
The result of
s + 1is anint, not auint16_t. Because of the way that the conversions work, its very easy to accidentally end up with very unintuitive behaviour that I suspect nobody has ever wanted. IMO integral constants should not be typed, and instead should pick up their type from the surrounding contextAlso while i'm here,
intmax_tneeds to get sent off to the special farm, and this is before we even get to how crazy floats are in C++13
u/HommeMusical Jun 25 '26
I mean, following this subreddit pretty well summarizes all my issues with the language, which I started using around 1987.
The biggest category is this: a lot of simple questions about the language have extremely difficult answers. There are footguns everywhere, and for programmers at all levels.
The canonical example - but there are hundreds of others - is this thing which I have had to explain to a dozen beginners: that
return std::move(x);actually prevents the RVO. The conversation always starts, "But don't I want to move the contents?" and I think, "That's so reasonable!"Now, I fully understand this but each time I try to explain it to someone, I'm aware of how gnarly this is.
I mean, rvalue, lvalue, xvalue, glvalue, prvalue, a lot to ask someone to understand before performing assignments or return statements.
Please don't analyze this specific example. As we all know, the language is filled with unexpected behaviors, like the most vexing parse (which luckily is rare).
The second category is the frozen nature of the language. It seems like no change will ever be allowed that will ever break perfect binary compatibility back to around 1980, and any idea like "epochs" where a compiler flag can gives you a new "epoch" of the language that loses some old cruft seems like it will never get past the committee.
It feels like the whole language is being held hostage by a few people who lost their source code in the Reagan administration.
And finally, the community.
6
u/artyombeilis Jun 25 '26
Other than that - it is working horse of serious development
6
u/GYN-k4H-Q3z-75B Jun 25 '26
Build times.
1
u/SubstanceHot5190 Jun 26 '26
Thank you all for the responses! You all are quite a bit more focused and detailed than r/c_programming. This was very helpful!
5
u/IllustratorSudden795 Jun 25 '26
It's not safe to access captured variables from within a lambda coroutine after first suspension - it makes perfect sense why this is the case but it is too easy to make this mistake and I always do and scratch my head why the program segfaults.
13
u/TehBens Jun 25 '26
There are a few parts that nobody uses or people try to avoid because there were critical or major oversights.
u8 strings come to mind. regex API is known to be very counter-intuitive.
14
u/KazDragon Jun 25 '26
I don't like the irregularity of the grammar. Rebooting the language with nothing but a fix for regular grammar would easily drop compile times by half, of not more.
14
u/Jakabxmarci Jun 25 '26
since you ask about keywords, I hate the ambiguous use of keywords
static,inlineandconst, and would redesign their usageand I would probably remove the
unionkeyword although I acknowledge it may have some uses.4
u/shapul Jun 25 '26
The preprocessor.
4
u/domiran game engine dev Jun 25 '26
A lot of good mentions. Let me add that it has so much duplication because nothing is ever deprecated and removed. I'm looking at you, std::function and std::copyable_function.
On top of this, crap like std::regex stays broken because no one wants to break ABI.
Hell, msvc's std::string_view can be a footgun because it has a user constructor, thus cannot be passed to functions as two registers.
6
u/PaganGuyOne Jun 25 '26
Just got back into playing with it a little bit, and I think what I don’t like is when all these new versions come out, and there’s all this amazing documentation about how they work, but then not even the latest compiler versions you can install on either Windows or Linux will allow you to use those features. Like how am I supposed to believe they actually work, if I can’t even use them on the latest compilers that you can download? I don’t like that my version of g++ and clang++, which are supposed to be the latest versions since I installed them this month, can’t even utilize C++26 features and libraries.
I put together a little test for myself of using stacktrace from 23 with no problem (not that I actually liked what I made when I realized what it was actually doing at the end of my code).
But then after that I was trying to put together a program using <hazard_pointer> to create job tickets, but my code wouldn’t compile, and there are no flags that will work because it doesn’t seem like the latest version of my compilers have it as a feature.
I’m still a newbie at this, and I’m still kind of getting back into it, but if there’s anyone who knows how to help me, it seems like people have been utilizing 26 features in their code for a while now, and I would love some help getting compatibility with c++26.
3
u/phi_rus Jun 25 '26
constexpr std::string
I understand why that's not possible, but that doesn't mean I can't want it.
9
u/rlbond86 Jun 25 '26
Nearly every design decision has turned out to be at least partially a mistake in some way, and now we're stuck with them all.
Implicit constructors and conversions, exceptions, initialization, many standard library decisions, implicit self parameter, non-destructive moves, ranges, etc.
They won't break ABI or even introduce epochs. Every feature is added through the standard library instead of the language "for compatability" which makes them obtuse and slow to compile.
The language is missing so many features compared to Rust: match expressions, control flow as expressions, async, explicit mutability, early return are just a few examples. And the features that they do share are way more ergonomic in Rust. Compare Rust enums with C++ variants for just one example. The visitor pattern is incredibly cumbersome compared to Rust's straightforward match expression syntax, but because variant is part of the standard library instead of a language feature, we're stuck with it.
7
u/mkrevuelta Jun 25 '26
Undefined behavior in a few things that were perfectly defined (and used massively for optimizations) in the 8086 assembly language.
I don't care if there's other hardware that traps, excepts, explodes or flies demons out of your nostrils. The most common computers simply wrap around in 2's complement and that's OK.
Declaring it as undefined behavior and letting compiler vendors implement aggressive optimizations basing on it... FFFUUUU!
Yes, I know there's a GCC compiler flag for this. Still, these things should be implementation defined, not undefined. And they should be "opt in" one by one, not "opt out".
2) Corner cases of bit shifts.
This is a completely different case, cause it's not C++'s fault. IIRC, it was AMD who decided to save a handful of transistors, (and maybe a few picoseconds!?) by just using the lower bits of the second operand, not checking whether it is greater or equal to the number of bits of the first operand.
AMD won the 64-bit battle because their proposal was way more compatible with Intel's 32-bit platform. But they cut corners in this detail and now we need to check for the corner case with a cost that is a hundred times higher than the savings.
Again, having it as undefined behavior allows the compiler to silently discard our code by producing an executable that runs faster by not doing what we wanted.
This race for the performance has thrown C++ under the wheels of the bus. Old code recompiled with aggressive optimizations suddenly has security holes.
Fuel for the rise of allegedly secure languages.
7
u/spartanOrk Jun 25 '26
It doesn't have `cargo` or `pip` equivalent. This is criminal, in 2026.
6
u/AnyPhotograph7804 Jun 25 '26
I do not like the obsession with undefined behavior. But finally they get rid of it, even if the progress is slow. Having erroneous behavior instead of undefined behavior is much better. But it is still not optimal. IMHO they should turn every UB, which is detectable at compile time into a compiling error. And no, this would not break the backwards compatibility.
2
u/RQuarx Jun 25 '26
the fact that everyone doesnt use meson!
2
u/enl1l Jun 25 '26
Compilers should be focusing more on improving compilation times
2
u/Kadabrium Jun 25 '26
Reference isn't written as a suffix to the var name T var&. This would made it both visible at the call site and the declaration
2
u/Professional_Top8485 Jun 25 '26
Long stack traces.
2
u/Mougrouff Jun 25 '26
Sometimes meta programming techniques can shadow compilation errors like vampirsim then lead to cryptic crashes
2
u/CyberMarine1997 Jun 25 '26
I don't like how utterly gigantimongous the current standard is. It should be divided in two: the language and the library. Plain and simple. With two standards, they can evolve separately. The standard committees are already organized this way: why not the standard (ahem... standards)?
2
u/Intelligent_Hat_5914 Jun 25 '26
Seg fault or which line caused it
2
u/Ulrari Jun 26 '26
I wish C++ had a once statement. There are already ways to achieve similar behavior, but I think it would look much cleaner if we could write it like this:
void Foo() { once { Init(); } ... }
2
u/chibuku_chauya Jun 26 '26
Growing complexity, C legacy, initialisation, eternal ABI and its role in the accretion of features that are meant to replace older features which are themselves never removed from the language, std::regex, std::vector<bool>, designated initialisers which cannot be listed out if order like with C99.
2
u/KiwiMaster157 Jun 27 '26
If I don't get a time machine, I'd like to see std::vector<bool> deprecated and replaced with a separate std::dynamic_bitset type type. Eventually we can remove the specialization and have std::vector<bool> work the way people expect.
8
u/OwlingBishop Jun 25 '26
The uninterrupted stream of wankers asking sterile and loaded questions about the language.
3
u/mikeblas Jun 25 '26
Seems like a C++ developer will spend a lot of time yak shaving at the expense of spending time on task. A low task to yak ratio is deflating, sometimes defeating.
3
u/vI--_--Iv Jun 25 '26
Design by committee
3
u/Impossible_Site7605 Jun 25 '26
shills on this sub who think ai will make a game in c++
2
u/AKostur Jun 25 '26
When you can make me believe that this question is being asked in good faith, then maybe I’ll consider actually answering it.
1
u/Daemontatox Segfaulting Jun 25 '26
Mostly build system and the people , some of the community are just so bad to deal with.
1
u/all_is_love6667 Jun 25 '26
long compile times
1
u/[deleted] Jun 25 '26 edited 10d ago
The original post content no longer exists here. The author used Redact to remove it, exercising their right to control their data & privacy.
Saffron harbor saffron waffle amber velvet
1
u/dynamic_caste Jun 25 '26
Excessive commitment to backward compatibility.
Lack of customizable functions
1
u/Careless_Bag2568 Jun 25 '26
Maybe some strange keywords
1
u/dexter2011412 Jun 25 '26
drop the legacy baggage
1
u/Modi57 Jun 25 '26
I know, it has no statistical soundness whatsoever, but I find it very funny, that the cpp version of this question has way more answers
1
u/[deleted] Jun 25 '26
Compared to go and rust, package management is a literal nightmare
1
u/AdAggravating8047 Jun 25 '26
As for the language itself: the obsession with backwards compatibility. I understand the reasoning, but it leaves a lot of legacy issues. C++ is several languages tacked together, and being able to write code as it was written in the 90s makes teaching the language or onboarding devs much harder (and consequently leads to a lot of C-with-Classes teachers).
The ecosystem is the bigger problem though. Package/dependency management, cross-compilation and build orchestration/scripting can be a major pain in the ass. That cmake is the least worst option is a travesty.
1
u/CandyCrisis Jun 25 '26
Committee's inability to get serious about memory safety, wasting precious time on solutions that definitely won't work.
1
u/House-00 Jun 26 '26
I hate the STL’s naming conventions/style. I wish everything was standardized in something like PascalCase.
One major thing I wish was changed besides naming conventions would be a strict requirement to specify mutability/immutability. Every variable should be required to explicitly state what its mutability is. I prefer verbosity and clarity, and I think this is one step closer to achieving that.
1
u/Ok_Spring_2384 Jun 26 '26
I wish I did not have to learn the syntax of a domain language to build projects that need libraries….
1
u/Resident_Educator251 Jun 26 '26
The developers who can't stop thinking the best thing that ever happened to programming was c++.
1
u/pleaseihatenumbers Jun 26 '26
move semantics should have been a thing from the beginning instead of being a feature bolted onto the language; it should be actually impossible to refer to the moved-from object, like in rust, and from the programmer's PoV it should just be a trivial operation (with some exceptions)
1
u/MagicalPizza21 Jun 26 '26
This is missing:
template <typename T> std::ostream &operator<<(std::ostream &in, const std::vector<T> &vec)1
u/keithstellyes Jun 26 '26 edited Jun 26 '26
I'm one of those "I was a C and Java dev but wanted some of the QOL in C++ so went to C++".
The big headache I come into as a C person...
RAII escape hatches are too painful RAII I largely like, but no-args ctor being automatically called when you allocate memory for a class unless you basically "trick" the language standard is a bit annoying.
For example, I was integrating with a couple C libraries for image parsing, JPEG and PNG parsing looking like
But of course, my Color() constructor was called every single pixel, even though the data was getting overwritten which resulted in a noticeable slow down. I ended up just getting rid of it which was able to get optimized out.
Similarly, if you have a class that has something like a file handle, or other non-trivially constructable class, it's a pain to use it in other data structures and feels like you're fighting the language
1
u/Desperate-Data-3747 Jun 26 '26
using RefInt = int&&;
RefInt(40);
What to guess what that calls?
1
u/hgstream Jun 27 '26
Most things I realized I do not like about C++ came to me after some time of doing Rust. I will try enumerate a few:
Of course, the language is very old and far from perfect, but I believe there could be improvements only if there was some branching of the language, where for example I could specify to use C++69 (or whatever) and it is stripped of lots of old features.
1
u/Aakkii_ Jun 27 '26
I wish it was memory safe and still efficient! But wait…? 🦀
1
u/megayippie Jun 29 '26
Lack of plot. Really need it for debugging. Main reason I use (and seldomly contribute to) nanobind for python
1
u/heavymetalmixer Jun 30 '26
1
u/fdwr fdwr@github 🔍 Jul 14 '26 edited Jul 15 '26
I would love logical block two keywords, including ones to:
defer(not Go's brokendefer).With block deferral, this...
...just becomes:
With a verify/check sort of keyword too, this Win32 code...
...would reduces to a more visually clear flow of:
And overly nested exception code (example from here) like this...
...would reduce to just:
And COM HRESULT calls simplify from...
...to:
Mind you, there are often macros defined for these cases, like
RETURN_IF_FAILED(StructType->GetFieldByIndex(i, &field));, but I'd rather eliminate the macro need.1
u/compulsaovoraz Aug 23 '26
Honestly, I think error handling could be better. Like Go
1
u/Gabriel_soul Oct 20 '26
Lots of implicit conversions
1
u/WikiBox Jun 25 '26
There should be a simple GUI library in the standard library. Light-weight and extendable. Just a basic minimal cross-platform wrapper around a generic hardware/OS-specific GUI-libraries.
Doesn't have to be very good. Just good enough so (new?) programmers can use it in simple "Hello World!" programs and basic utilities.
1
u/rlinED Jun 25 '26 edited Jun 25 '26
Someone had to drop this here: https://www.youtube.com/watch?v=7fGB-hjc2Gc
Even working with cpp for some years myself, i wasn't really aware of the boatload of poor design decisions that are actually in cpp.
1
u/GhostVlvin Jun 25 '26
exceptions are ridiculously slow. I understand that this mechanism wasn't meant to be used casually at runtime, rather like emergency case, but it is still used in runtime a lot and it may be faster. Afaik in java and C# it is cause it is so basic there to wrap all in try-catch blocks and to throw exceptions
1
u/slowbowels Jun 25 '26
just get rid of header files already ffs
1
u/RidderHaddock Jun 25 '26
It's gotten too complicated.
I started using it in the early 90s, so learned the new stuff bit by bit. Anyone coming at it now are doomed to fail.
"But only use the good parts", you say? Sure, we can all agree on that. Unfortunately we're never going to agree on what those good parts are.
Some people love templates. I loathe them. Partly because of the syntax, but mostly because of SFNIAE.
I love lambdas. Some colleagues don't.
I despise UB. Some people disagree. They are wrong, I am right. Period.
Concepts? Sounded great at first. The actually implemented (gimped) version? Not so much.
Annotations? Yuk.
Preprocessor? Handy, but incredibly overused, resulting in unnavigable messes.
--
I would like to do a Python 3 on steroids and make one huge break with backwards compatibility.
I've used C++ so much it's still the language I pick up by default, even for tasks where it's an objectively silly choice. But honestly, if Rust would introduce OO inheritance I would make an effort to switch ASAP.
1
u/mrmike123 Jun 25 '26
at an API level, a lot of things for the std library help avoid the pitfalls of C and old C++ like RAII wrappers such as unique and shared pointer. But there’s always a method that can be used to break out of the safety mechanisms or hack around these guard rails
Honestly I think the argument that C++ is unsafe etc isn’t always true if you stick to modern std usage. But in my experience so many weird and annoying bugs come from someone calling these methods and breaking things like ownership models
1
u/Neur1n Jun 25 '26
Standard C APIs, concurrency, compile-time computation and instantiation. That's all I need.
1
u/Responsible-Bar7165 Jun 25 '26
C
1
u/Sentmoraap Jun 25 '26 edited Jun 25 '26
Signedness and overflow behaviour should be orthogonal.
I would make overflow UB by default on all types, and add fonctions and types that supports overflow for when you want it.
It would give a bit more optimization opportunities, and could detect unwanted overflows in debug.
1
u/drkspace2 Jun 25 '26
Bite the bullet and fix/remove things that break the abi, remove vestidual functionality, and remove things that only exist because it is in c.
1
u/RoyBellingan Jun 25 '26
The thing I hate the most is that is taught badly to inexperienced person, so they remain "scorched".
Than once those people start to learn and understanding CS they are exposed to newer, (simpler) poorer language.
So now you have a bad memory and a fancy new thing, the result is people with low experience and who do not know the language advocate against. Is not always the case, but in my personal experience most of the people who advocate against had very low knowledge of the language and where in a C++03 state.
Also they confuse C and C++ regularly, and blame C++ for the fault C while considering "pure C" as something superior, which reinforce the fact that they have no idea what they talk about.
1
u/pjmlp Jun 25 '26
I would drop most C stuff, force proper strings and arrays.
Anything coming from C headers would require [[unsafe]] annotations.
1
u/Spyromaniac666 Jun 26 '26
all the annoying baggage from C lol
-2
u/MrPhi Jun 25 '26
Declare end of life for 2050 so people can prepare migrating to langages with less historical debt.
C++ is very entertaining to follow, some very smart and passionate people have made a lot of work to help it grow.
However C++, because of its historical debt is so convoluted, so needlessly complicated and limited in its capacity to prevent avoidable human errors that I feel updates made to make it survive are hurting computer development as a whole by limiting the visibility of the now mature enough alternatives.
0
u/Ateist Jun 25 '26
Most of all I hate lack of standardization for intermediate files.
0
u/Asleep-Mall-6940 Jun 26 '26
Remove the entire stl, all keywords newer than 1999 and add C like struct and union initialization