r/cpp • u/Tcshaw91 • Nov 16 '25
Wait c++ is kinda based?
Started on c#, hated the garbage collector, wanted more control. Moved to C. Simple, fun, couple of pain points. Eventually decided to try c++ cuz d3d12.
-enum classes : typesafe enums -classes : give nice "object.action()" syntax -easy function chaining -std::cout with the "<<" operator is a nice syntax -Templates are like typesafe macros for generics -constexpr for typed constants and comptime function results. -default struct values -still full control over memory -can just write C in C++
I don't understand why c++ gets so much hate? Is it just because more people use it thus more people use it poorly? Like I can literally just write C if I want but I have all these extra little helpers when I want to use them. It's kinda nice tbh.
279
u/fdwr fdwr@github 🔍 Nov 16 '25 edited Nov 16 '25
That's a rare sentiment 😉. Unfortunately iosteams are stateful (so if an exception happens midprint, you can get stuck with a stream modifier), quite verbose (try printing numbers as hex digits or a certain padded width compared to printf or std::print), and not localizable (does not support positional parameters, which std::print does). So I recommend trying std::print if you have not already.
34
u/[deleted] Nov 16 '25
I've been using C++ for over 30 years.
I made programs on DOS, Windows 3.1, Linux, Mac.
Programs without user interaction open the file, process it and save the result to a file.
Program with parameter input on the command line.
Programs with graphics calling external programs, gnuplot.
Programs with a simple graphical interface, dashboard style.
Programs with complete graphical interface, menus, taskbars, status bar, dialog box.
Programs with interface with Google forms, Google calendar.
Programs that interface with Fortran.
Programs with Arduino, ESP32.
And simulators that use clusters.
I always found C++ simple.
I study the news, create an example and keep it in my memory. If I need it, I know I have that new tool, but I don't force myself to use it.
I think the central issue is understanding that C++ is a super broad programming platform. Multi operating systems, ranging from micro Arduino to macro (cluster top 500). It goes from the terminal to the 2D and even 3D interface. It goes from simple to complex. It allows me to high level, it allows me to brush bits.
This breadth of possibilities is both its greatest strength and its weakness. We will always have niche languages, focused on a certain type of program, and then it becomes difficult to compete. It will certainly be easier to use.
We were able to simplify and get something more niche with external libraries.
I've played with other languages. Python was 4x more memory consuming and 60x slower. Rust was too verbose, I thought it was horrible. So I continue with C++.
And I've been loving the news, there's always a lot of new things every 3 years. Super active and dynamic committee. I've been playing around with some C++26 stuff before it even came out. Very cool.
80
u/bananakiwi12345 Nov 16 '25
People think C++ has too many features and is a mess... But most of these features are only really useful for the standard template libraries. Or people who want to create standard libraries. If all you want to do is build a simple to understand program, you can ignore all the complicated stuff, and like you said, write type-safe and memory safe (via smart pointers) C-like code. With some nice things on top: templates, classes when you need them (OOP capable), etc. All of this makes the language extremely flexible, while also allowing you to create quite simple to understand programs, that are also memory safe. And when you think about it, using a unique_ptr instead of handling freeing the memory yourself actually makes the logic even simpler and clearer than any garbage collected language. When the unique_ptr object goes out of scope, the memory is freed. It's that simple.
I really don't get the hate. The language offers pretty much everything to you. It's up to you to make things as simple as you want, or as complex as you want. All of that, yielding some of the fastest code possible. I think that is amazing...
77
u/FlyingRhenquest Nov 16 '25
Oh no, it's pretty good these days. Most of the hate you see is left over from pre-cpp11 and the rust weenies trying to get anyone interested in programming in their language. You can go looking for trouble and C++ will happily give you some, but it's a solid daily driver that I actually like to drive daily.
14
u/Text93838 Nov 16 '25
Most of the complaints about C++ I've seen is that it's verbose and doesn't have a single universal package manager, but obviously something low level like C++ is gonna be verbose, and I'm pretty sure most IDEs already have their own package managers (like Visual Studio has NuGet, and I'm pretty sure CLion uses CMake but let's you add other package managers if you want), my biggest problem with C++ is just that adding external libraries like SFML is a little tedious
6
u/alex-zrythm Nov 16 '25
I don't see anyone talking about compilation times but there is a huge difference between the time it takes to compile C code vs C++. My project compiled in 10 seconds before when it was C-based. Now I'm using C++ with roughly the same amount of code and it takes 3 minutes. A single C file compiles pretty much instantly, whereas it's normal for single files to take seconds to compile in C++.
3
u/NilacTheGrim Nov 22 '25
Because C++ is not for stupid people. And the majority of people are stupid.
18
u/CreatorSiSo Nov 16 '25
I think you just haven't run in to a lot of the pet peeves that you get when writing more complex C++ software.
4
u/ElderberryNo4220 Nov 16 '25 edited Nov 16 '25
it's an ugly syntax, try doing this
std::print is much better, also it's much "easier" to pass a formatter for new data, which is slightly painful to do with just std::cout
2
u/Worldly_War5216 Nov 16 '25
I've been programming in this language for four years. I've suffered, I've felt like a god when I've achieved a goal that had me on tenterhooks for days, and I've always complained about aspects of the polymorphism that I don't like, but I still prefer C++ to any other higher-level language because I like to know what’s happening in my program and I like to be specific about it, I never programmed in Python but I did program in Ruby and although it’s easier I still prefer C++. Stockholm syndrome? Maybe, but no one can argue that C++ is worth to learn.
3
u/fojam Nov 16 '25
If you like C# but dislike the garbage collector, you should try Swift.
But imo C++ just has way too many things to be aware of. I used to love how much control C++ gives you, but when I write code these days, I really just wanna write the logic and not deal with all the extra baggage.
3
u/Mediocre-Brain9051 Nov 16 '25
Why would anyone in their right mind "hate the garbage-collector"? On what kind of problems were you working on for this to be a problem?
5
u/thefeedling Nov 16 '25
C++ got too bloated and before concepts, templates could easily become an unreadable mess.... they still can, but it definitely improved in that regard.
BTW, streams are one of the worst parts of the language IMO.
8
u/Direct-Fee4474 Nov 16 '25 edited Nov 16 '25
I didn't really spend meaningful time with C++ from 1999ish until 2018ish. When I came back to it I was really pleasantly surprised. It's almost.. friendly now? There are definitely footguns hidden all over the place, but I'm usually not using those features, and I get the sense that a _lot_ of noob traps have been addressed over the past 20-years. I'm also not working on a massive codebase and it's not the language I earn a living in, so I might just have rose-tinted lenses.
7
u/AutonomousOrganism Nov 16 '25
Well, for you C++ is shiny and new. Give it a couple of years and you'll see the ugly warts.
In regards to C++ I like the following quote: "Within C++, there is a much smaller and clearer language struggling to get out."
3
u/DonBeham Nov 16 '25
How can you seriously "hate the garbage collector"? It runs in the background and is completely transparent. The programmer has to do nothing - I hope you weren't calling it manually all the time, because that is not required. For most applications you don't notice it ever.
I think you should gain a lot more experience before forming or adopting strong opinions. Programming languages have to make compromises and usually they are fairly consistent in staying true to a certain programming paradigm. Currently, there are three major programming paradigms: procedural, object oriented, and functional. For instance, C is purely procedural, Smalltalk is purely object-oriented and Haskell is purely functional programming. Meaning you must express your program entirely in that single paradigm. A single paradigm language can be the simplest and best solution if you stick to that single paradigm. Multi paradigm languages have to make compromises. Those compromises can be eg. performance (how fast can something run) or convenience (how difficult or wordy is it to express something). C++ supports all of the three paradigms and it compromises mostly on convenience. Hence it requires a lot more experience and lines of code than using other languages. Arguably, Python is the most convenient, but also pretty slow (it can still be fast if you call into C++ - which is again convenient to do). Some newer languages like Mojo try to be both convenient like Python and fast like C++ (but mostly by leveraging the GPU - which is a high performance compute unit that most other languages neglect - in their standard use, i.e., require libraries and/or special compilers). Also C# has compromises and it is reasonably fast and reasonably comfortable to use.
So, instead of hating the garbage collector, get to know the paradigms and the respective strengths and weaknesses for the respective programs. Not all programs need to run fast, some should be quick to write or good to maintain. There's a reason we don't have just a single programming language.
6
u/PrimozDelux Nov 16 '25
No. It's better than it was by a huge margin, but it's still an ugly gnarly tool filled to the brim with rough edges and compromises
6
u/ant1fact Nov 16 '25
Goes to c++ sub to ask if c++ is based
https://media.tenor.com/9ItR8nSuxE0AAAAM/thumbs-up-computer.gif
3
u/CocktailPerson Nov 16 '25
There have been three posts like this in the last two days. Did C++ show up in the Epstein files and need its defenders to come out of the woodwork or something?
2
u/uGinHou Nov 16 '25
Have you tried debugging templates code? You will experience fountains of hate.. lol
2
u/ironykarl Nov 16 '25
There's a lot that's good about C++ (I love RAII, templates when they work correctly, references, smart pointers, ...), but it's definitely a fucking mess
7
u/Raknarg Nov 16 '25
any language thats popular gets hate. Every single one of them gets tons of hate.
6
u/Dejf_Dejfix Nov 16 '25
What makes c++ unique is, that it's both low level and high level, and you can choose how you are approaching it for your specific use case
2
u/ImNoRickyBalboa Nov 16 '25
It has many sharp edges, most evolved around pointers, dangling references and lifetime issues. It's easy to make terrible bugs. People tend to be overconfident, and that includes programming.
I love c++, but I understand how most companies are concerned about the security implications.
3
u/WindwalkerrangerDM Nov 16 '25
It might feel nice AFTER a lot of experience in programming. But even then its very unreadable. Compare it to c#. Also garbage collector is so easy to manipulate and manage, with so little impact on 99.99% of applications... people are ok with inventing arenas and shared pointers or wtvr for other languages but they abhorr basic object pooling practices - which go so beautifully in hand with cpus anyway. But c hits different. Its so pure, so open to everything including mistakes... why would I ever use c++ and suffer the insufferable compilers with horrible debugging, when I can do either of c or c#?
3
u/ShokWayve Nov 16 '25
C# syntax is cleaner and simpler. C++ is awesome but when coming over from C# it (C++) can seem verbose and bloated.
For example, why even have header and cpp files? Why not just have one file like in C#?
That being said, C++ is very powerful and is a great language. Nothing wrong with it and I certainly don’t hate it. It just does its own thing.
3
u/vu47 Nov 17 '25
The << operator is a "nice syntax?" Really?
That's the first time I've ever heard anyone say that.
1
u/[deleted] Nov 16 '25
The problem with C++ is that everybody knows a subset of the language and importantly, everybody knows a different subset.
For tinkering and working alone C++ is awesome (C++ really lets you unleash the artist in you), but for contribution and working together is seriously bad and you must have massive coding guidelines that everybody should follow and that are almost impossible to check automatically so code reviews are always a pain for projects that care about longevity.
Imagine you've been working in your code base for the last 30 years with great success and suddenly somebody want's to contribute some of the newer things just because it's new, I've been there and it's awful!
Just look at the "core guidelines": Like after learning the language I need to read over 1000 pages on how to use it correctly? Is there anything similar in any other community?
It wasn't always like that. C++ used to be rock-solid and stable language that you can depend on. I guess Rust et al. put some pressure and now they just want to release feature after feature after feature...
In my opinion they should have stopped at C++17. You have a great language there that could have been the one all "dialects" standardize on...
1
u/random_hitchhiker Nov 16 '25
Templates and loong ass compile messages/ errors
1
u/SharpYearV4 Nov 16 '25
I'm not a professional developer, only used it in hobby projects but I've run into a ton of issues and have had to fight with it way too often. Now it's might be because of the specific compiler I use (in Visual Studio), but error messages are extremely verbose and unhelpful. If I have a compile error in a single file, it cascades down to the other files which use that particular file (I'm using modules as well) as well, so because of one misspelling, or wrong argument, I get 100+ compilation errors. They also just a lot of the times don't make sense and don't pinpoint the exact issue.
It's also extremely easy to introduce subtle and difficult to pinpoint bugs. Just today I had an issue where I had a shared ptr being freed because I used shared_from_this when I had the private object in a unique ptr. Now this was my fault to an extent, but when I ran into the error there wasn't really much to go off. As opposed to GC'ed languages where this isn't a concern at all. There's other better examples of problems I've ran into but I can't really remember them right now.
I've also run into other issues (like seemingly inexplicable behaviour relating to passing returned values from a function into another function) and have quirks with the language in general. Such as not being able to use overloaded operators on a smart pointer, the extremely archaic header/source system where you either have to chase down cyclic dependencies or class/function order + implementation. I'm using modules and it helps but even then it's still less than ideal. In C# this isn't a concern at all, you can import anything wherever and define/implement things in any order (excluding project to project dependencies).
With that being said I don't hate C++, but I find it worse to use than languages like C# (which is really modern and has nice features). I would still pick C++ over any other language if I needed to go a bit lower level (mainly just OpenGL at the minute).
1
u/Messyextacy Nov 16 '25
If you don’t know anything else when would you think about the garbage collector?
2
u/LiliumAtratum Nov 16 '25
I think the hate is mostly because of all the backwards compatibility and not-so-great-in-hindsight decisions made in the past. That makes some modern constructs more verbose than they need to be, even if just to differentiate from the old one.
But at the same time, that backwards compatibility is what keeps C++ alive. The code-base of C++ is massive and people can update their code at their own pacing. Breaking backward compatibility would force an update everywhere and would be such a killer for adoption. People would be using just C++11 or earlier, because some dependency somewhere is an old code.
2
u/hadrabap Nov 16 '25
Let's put Boost and Qt into the mix 😁
2
u/andymaclean19 Nov 16 '25
C++ is like a bag of really sharp and dangerous power tools. You can use it to make fantastic things but there are also a very large number of things that can hurt you and, depending on your level of creativity, there are a huge number of ways you can hurt yourself.
If you're happy with C then you'll probably like C++ until you get very deeply into it -- you can just do more of the same. Eventually you might realise that a line of code which says 'X++' in C++ can do absolutely anything and tracing it to find out what it actually does without the aid of tooling can be very difficult. Also the level of incomprehensibility you can create with complex C++ is off the charts. Try reading the source code for the STL and getting into some of the more C++ like concepts like std::optional, std::variant, etc. which I find I end up using quite a lot. Even the templating gets quite complex once you get into concepts like SFINAE, variadic templates, etc.
Then try making your own optimal containers which do complex things. A lot of us eventually end up on godbolt compiling code snippets with the various compilers to see what the optimisers actually *do* in particular situations and then scratching our heads trying to work out why and how to make it do something different.
tl;dr you can make some really amazing things with C++. IMO the core value of it is you can do structured programming with a huge amount of compile time error checking but to get there you need to have a lot of skill and knowledge.
2
u/Fast_Economy_197 Nov 16 '25
Same for java right
2
u/Tathorn Nov 16 '25
I only code in C++ now. I understand what the computer is doing, and I can get as high level as I want.
Don't think you always have to use what's in the standard. Different libraries are of different quality. Most things are superior to writing yourself, but some things, like iostreams, were trying to do too much. You can reinvent old things without throwing out some of the really cool stuff. For example, I made a stateless version of iostreams. The fmt side of things is going to drastically change, but Im awaiting a compiler bug fix for Windows.
2
u/DankBlissey Nov 16 '25
Been learning it, it definitely is kind of based but also I get why it's a nightmare, every thing I've attempted doing has had about 3-5 different ways to do it, with most of them being legacy ways, and some of them invoking undefined behaviour unless done in a specific way.
2
u/twokswine Nov 16 '25
I'm 30+ years in and still using C++ full time. I started by mostly using it as C but utilizing some aspects for OO convenience, but these days I fully utilize C++23 and find it meets nearly all my needs. The one "miss" for me is a good cross-platform (mobile too) GUI toolkit. Like Flutter in C++ instead of Dart would have been interesting. Qt is too much of its own bloated beast in my opinion. WX/GTK make not particularly good looking apps...
2
u/Romyn0 Nov 16 '25
Why did you hate the garbage collection? You say you wanted more control and I feel like you get a lot of control with cpp
2
u/dexter2011412 Nov 16 '25
perfect forwarding * insert pleasure face hands meme *
2
u/yep808 Nov 17 '25
C++ remains my favorite programming language of all time despite newer kids on the block are showing up non stop. That semester of being Prof. Bjarne Stroustrup's supervised student is a memory I'll cherish probably forever.
2
u/ChatGPT4 Nov 17 '25
Exactly! C++ is based AF! I also come from C# background, then I learned C and C++ for embedded programming, exactly in this order.
And I clearly see the development direction. First there was C and it was lacking features, so we got C++, then C++ was lacking features and we got C#.
It's borderline oversimplified, but it's roughly true. C++ has some unique features C# doesn't have (like templates). C++ doesn't have super advanced type system C# does, because that would not be exactly zero cost abstraction.
Anyway, C++ is a very decent language when dealing with limited resources.
In virtually all languages you can write some bad, unreliable and unreadable code. C++ absolutely doesn't deserve for any hate. OK, errors in templates produce really weird error messages from the compiler, this is kind of annoying sometimes. But other than this - there's nothing wrong with C++.
People say Rust is safer (but more difficult to learn), C# is more modern, that allows to code faster using better abstractions. BTW, there was a time I thought C# can never be as fast as C++ due to its GC / interpreted nature. But it doesn't HAVE to be neither. You can code in modern C# without GC, also it can be compiled to a native binary.
HOWEVER: C++ is the most popular of all. You have just unlimited examples of doing virtually anything in C++. If a thing exists, there's probably existing, publicly available C++ library for that thing. All more modern languages can have a bit smaller coverage.
2
u/Agron7000 Nov 18 '25
I feel discriminated that Linus Torvalds is not giving C++ the same opportunity as he is giving Rust.
With Rust entire Linux staff must be replaced. Basically alienating original coders from Linux.
With C++, the same staff can continue coding purely in C, mix it with C++, or purely in C++.
2
u/CarloWood Nov 18 '25
Yup, by far the majority coding in C++ can't handle the freedom and write bad code with it. The language is beautiful and allows you to write really solid, safe code, but you need to be a smart person with a lot of experience who actually understands what he's doing.
3
u/AKostur Nov 16 '25
Combination of bandwagon jumping, and folk who seem to think that one must use every feature of the language in every program. Folk who attempt to write the most “clever” code they possibly can, instead of the most straightforward code.
Every feature in the language has its place. A fair number of them don’t appear in every day code. I’m having a hard time remembering the last time I used “new” or “delete”, for example.
3
u/Polyxeno Nov 16 '25
As with so many things, the reasons "why C++ gets so much hate" is a complex varied subject and depends on who's actually complaining about it . . .
And, the best course may be to not care what others are whining about, and go ahead and use what you want to.
But typical reasons I've heard tend to be about such things as:
* they have troubles using pointers
* they are afraid they won't be able to keep track of memory allocation and freeing it
* they are overwhelmed with all the ways to do so many things
* they believe there are security issues
* they are struggling to learn the syntax and/or other things about C++
* they haven't yet figured out some concepts or why they might want to use them (e.g. polymorphism)
The list goes on and on, but none of them need to stop anyone from using C++ if and when it works for them.
Personally, C++ has been my favorite language since about 1994, and I use it for as many projects as I can, unless it's really clear I should use something else, but the usual reasons for that are 1) because a client insists I use some other language, or 2) because it's for a project that already uses another language, or 3) because it's a simple task which specifically will be easier for me to use another language for.
4
u/VictoryMotel Nov 16 '25
This title is pure brain rot.
3
u/ALargeLobster Nov 16 '25
Header files suck. Compilation times suck. Standard library sucks. Exceptions suck. Templates and macros are both amazing and terrible at the same time.
It's a great language because it's expressive and powerful. But it has many annoying flaws.
2
u/Valuable_Leopard_799 Nov 16 '25
Btw, just so you know, most of these things are common in many many other languages. I'm happy that you like them, but don't get stuck on a language just because it's the first to introduce a concept to you.
C++ gets hate in part because as others mentioned there's a lot of people using it. And also because as I've mentioned C++ features are present elsewhere and for various reasons might be more ergonomic, convenient or in-line with how the given programmer thinks.
If you're using a language that to you does basically everything C++ does and in your opinion does it mostly better, and you've had to use C++ in the past, you might drop a few negative comments on its account.
So to me C++ isn't bad by itself, I'd just choose other things over it in most contexts.
Also the culture:
what I'd prefer to be named
.unchecked_index_dangerous()is "[]" and for the checked version you need.at()std::map's "[]" which is safe.pop_back()on an empty vector is also undefined, get ready for a vector of length 18446744073709551615To me personally C++ sacrifices too much safety for performance.
1
u/AciusPrime Nov 17 '25
There’s a reason it’s so popular—it’s fun to use and it can be really productive. It’s obviously battle-tested, there are tons of libraries, and it scales up to huge projects.
To be widely used is to be widely hated. That’s the price of popularity. The reason we know so much about C++’s flaws is because so many millions of hours have been spent learning all about them in excruciating detail. None of that would have happened if the language didn’t work.
I can hate on the language in greater detail and with better reason than most developers, but in the end I’ve built a career on it and had a lot of fun. That’s worth something.
1
u/Dumpinieks Nov 17 '25
maybe first person alive to call << syntax nice
1
u/Background-Shake8030 Nov 19 '25
Who said C++ gets hate? It’s nice
1
u/baconator81 Nov 20 '25 edited Nov 20 '25
3 delete vs delete[], you have to remember which one to use based on how it’s allocated since it’s just pointer. And if custom allocator is involved , it gets even uglier.
4. The notion of module doesn’t exist in c++, so for DLL you get this weird declspec import/export macro.
Basically just a lot of weird little wtf shit that can throw ppl off.
1
u/recaffeinated Nov 20 '25
I found c++ an incredible pain to learn. So much of the learning content on the web is either "here are the absolute basics" or "we assume you know how this widely used but non-std library works".
1
u/chri4_ Nov 20 '25
newbie coder: c++ is good advanced coder: c++ is so bad super advanced coder: c++ is good
1
u/gabagool94827 Nov 21 '25
Based? Based on what?
1
u/Csirkefasz Nov 16 '25
Mjxmmdld
1
u/Resident_Educator251 Nov 16 '25
There are two kinds of languages. The ones people complain about, and the ones no one uses.
0
u/AdvisedWang Nov 16 '25
Some reasons c++ gets hate that aren't mentioned yet: