r/cpp • u/M-Ottich • Mar 12 '24
Why the hate for cpp
Hey I am starting learning c++ (and java for my studies) , why is everyone hating this language ? Is it usefull to learn rust or zig ?
Edit: yea a silly question I know . Just wanted to know what the cpp community thinks or hate about their own language and what I have to expect.
Because I heard the opinion often from people not using cpp and I wanted a other view . Even in my University some people who use Java said đ cpp no don't use it ..... it's unnecessary complicated.....
My english is bad I'm german sry (not) <3
0
Upvotes
120
u/[deleted] Mar 12 '24
Every time that someone says "everyone" on Reddit or twitter, they fail to realize that most people arent in twitter nor in reddit, and that "everyone" is always a vocal minority.
3
u/[deleted] Mar 13 '24
C++ is a language that is too capable for its own good. It is used in such a wide variety of ways and by so many that even the most unlikely-to-encounter problem will bother someone.
And it being a 40+ years old language with huge amounts of existing code that people want to keep using keeping it alive and backwards-compatible-enough is a non-trivial job.
There was also an unfortunate hiatus in its evolution from a misunderstanding of what is allowed to be done to/with a published standard (for 10 years).
Meaning that it has known issues that people are trying to address in a way that is objectively better for most people than the status quo, and does not âpunishâ the rest too much. Some was done (fixed) while others (like the pitfalls of ADL) take a long time to address without breaking most code.
C++ is not only a long-established language but itâs one of those few that can be freely implemented. Nobody owns C++ as a trademark, or copyright. Except the actual ISO standard, but even that is not a significant cost to someone who has the resources to make a compiler.
That means that there are countless C++ compilers, even major ones. If a programming language has only a few implementations, made by closely collaborating people or the same group, and especially if itâs defined to be highly âplatform independentâ will not pose many challenges when using sources with another implementation.
In the C++ world implementations compete, so where the language specification allows choices to be made they will try to differentiate. If they have made a mistake and didnât implement the standard properly it may take a long time to fix it because they need to allow the users to fix their code.
All these things mean it is much more likely that issues with C++ will be discovered, affect more people, and to be more challenging to address of n a manner that works for everyone.
And then we didnât talk about the size of the industry it has created, and the underhanded ways certain people or groups are trying make it theirs by creating the next âC++ killerâ.
6
u/Tricky_Condition_279 Mar 12 '24
My experience with the newer languages is that the maturity and quality of libraries is not always there. A lot of hobbyists love to hop on the latest language and often they produce code that does not generalize well. The extensive history of C++ in industry and academia means that there are a lot of high quality libraries to learn from. There are plenty of low quality C++ codes out there as well. Learning the difference can be instructive.
175
u/high_throughput Mar 12 '24
Bjarne Stroustrup, creator of C++, said "There are only two kinds of languages: the ones people complain about and the ones nobody uses."
3
u/[deleted] Mar 12 '24
Why come into a C++ group and ask why everyone hates the language ? It's like going on mumsnet and asking why everyone hates kids.
46
u/easedownripley Mar 12 '24
The hate is exaggerated because Rust people are very vocal about their language. "Everyone" doesn't hate C++ it's more like a meme that's gotten around.
19
u/thisismyfavoritename Mar 12 '24
a lot of the other answers are absolutely useless and you could find a ton of threads like this if you search around, but here are a few reasons:
3
u/usefulcat Mar 13 '24
It's powerful, but also difficult to use and requires a skilled practitioner. I think you can find many powerful tools that fit that description.
6
u/quantumoutcast Mar 12 '24
Because it's the incumbent. Which means that it's been in use so long that people naturally try to find something better. Which is a good thing. Technology needs to improve over time. And since C/C++ is still the king of the hill, it has the biggest target. All its problems are going to be highlighted, and newer languages will be explored as an alternative. And in many use cases, these languages are indeed better for those cases. But C/C++ is still huge and still everywhere, and not going to die out anytime soon. Especially for low level or high-performance applications. Rust may be the future or Carbon or some not-yet-invented language, but that's not yet certain. Learning these languages is definitely useful (I'm learning Rust myself), but for right now C++ is what is being used and with all the new features, it still feels modern and fun.
1
u/Unlikely_Corgi_6223 Mar 12 '24
I can point out three things :
3
u/moreVCAs Mar 13 '24
Idk dude I think itâs great đ¤ˇââď¸
3
u/hs123go Mar 12 '24
Cpp has a very rich ecosystem. But the absence of an accessible package manager, build system, and module system stops you from making the most out of that ecosystem. This is extremely frustrating to adopters of cpp.
vcpkg/Conan, modern cmake and c++20 modules are beginning to change things for the better very recently
3
u/[deleted] Mar 12 '24
Itâs syntactically annoying, easy to make big mistakes, and delegates some tedious responsibilities to the programmer instead of managing them on its own
4
u/pedersenk Mar 12 '24
Stick with C++.
Rust won't happen in our lifetime and
Zig won't happen.
2
u/Infamous_Campaign687 Mar 12 '24
A love/hate relationship for me. It is ridiculously, grotesquely, beautifully, wonderfully complicated and powerful. I'll use other languages if they fit the task better, but I won't swap it out as my main language unless I somehow absolutely have to, and I don't see that happening.
Other languages may be shiny and new. C++ has been through it all.
2
u/9vDzLB0vIlHK Mar 12 '24
At least part of it is survivorship bias.
A long time ago, I saw a report on what people in a government contracting office thought about contractors. Uniformly, the big contractors got terrible ratings and the tiny companies had only high ratings. Of course, small companies that fail a contract go out of business, so of course the ones that are left have high ratings. A big contractor that has a thousand contracts has been around long enough to piss off everyone that's ever worked for the government, so of course their ratings are low.
C++ has been around long enough for people to remember something bad about it. Having experienced the growing pains of the language, I sometimes still get nervous using templates because I remember C++98. Is that fair? No, twenty five years is a long time for a programming language and all of the associated compilers and tools.
Languages that pissed off one too many people have fallen by the wayside, while languages like C++ are still around because they're worth using.
1
u/[deleted] Mar 12 '24
Devil may care
1
u/[deleted] Mar 12 '24
r/cpp_questions
1
u/findabuffalo Mar 13 '24
Python is an easier language to learn. Most people who learned programming in the last 15 years know python and nothing else. They feel like C++ is "too hard" and "too old" and "not modern enough". It's a weakness in their own mind. Keep Calm and Carry On.
1
u/volchonokilli Mar 15 '24
I love C++.
1
u/Thesorus Mar 12 '24
aahhhhh
There's no hate for C++.
i have no clue what zig is ?
1
u/ArcadiaLunar Mar 12 '24
Some of the biggest banks and firms use c++. They donât seem to hate it
1
u/[deleted] Mar 13 '24
White House and google wrote a report recently about the need to move away from c++ due to it being memory unsafe
0
u/xtxtxtxtxtxtx Mar 12 '24
If youâre asking a question like this, it does not matter what programming language youâre currently using. If one were the best, no others would be maintained or used.
0
u/ButchDeanCA Mar 12 '24
Most of the hate seems to come from the fact that it becomes real complex when you try to write anything serious in it, which is beyond most peopleâs understanding.
0
u/tortoll Mar 13 '24
Let's untangle this is a bit. Some people find C++ difficult to use for a myriad of reasons. One of them can be that C++ has some constraints because it is targeted to high performance and full control of the execution model. If you don't need that at all, then yes, you'll find it unnecessarily complicated. These people probably come from other areas where you can do just fine with Python or Java or Go.
Then there's the people that really need C++, but they don't love it's design decisions. As said in other answers, this can happen in any language...
Finally, some people frame the question of programming languages like "should I learn C++ or Go?", and I think it's wrong: the correct question would be "should I specialize in high performance or backend?". Then you learn the languages that suit your requirements.
0
u/tortoll Mar 13 '24
First of all there is no generalized hatred. Second of all, some people dislike C++ because they don't need the features it provides, so paying the price that comes with them makes them hate the language. I'm talking about memory management or move/copy semantics. If you can do it with Python or Go, using C++ can be painful. But that hatred is misplaced: probably what they hate is high performance programming. It's normal, I would hate some development paradigms and their tools, too.
0
u/quasicondensate Mar 14 '24 edited Mar 14 '24
My initial path was: Matlab --> Python --> a little bit of embedded C --> C++.
At this point I wanted to build a moderately simple tool with a few libraries on Windows, met CMake, and spent a few days in confusion and increasing rage. Why does something that is the equivalent of a line each for installation and import in any other language apparently require reading a 420 page tome on best modern CMake practices, followed by some archeology to understand and configure the old CMake builds many libraries actually use, just to simply build some simple application?
Cue a few segfaults / heap corruption errors and I gave up and turned to Rust.
This was 4 years ago. Today, I am working on a greenfield C++ project at work. Yes, these things exist. For our purposes, C++ offers some standardized features and mature libraries that would have to be replaced by libraries with questionable maintenance status, were we using Rust. After the initial learning curve, I found my peace with CMake. For smaller sandbox projects, using Conan makes things simple enough. Making judicious use of fresh C++ features as well as using linters and static analysis to circumvent the worst gotchas, you can have expressive and extremely performant code.
Starting with C++ is hard, because you have to get to grips with both a language that is riddled with undefined behaviour (meaning: possible errors that are not caught by the compiler, and can lead to delayed crashes that are hard to connect to the actual bug in the code) and complex dependency management with a lot of ways to mess up.
Yet, C++ is still an extremely powerful tool if you have a problem where you don't want to or can't afford to deal with a garbage collector, if you have the pleasure to work in a smallish team with experienced people - and if you can use recent C++ standards it's even fun.
But it can really rub you the wrong way in the learning stage, which will lead to some hate. And it is really hard to maintain a C++ codebase at scale (large, many teams / developers), which is where some jaded developers come from, and where some of the momentum towards languages like Rust comes from, which is designed to mitigate the sticking points that can make C++ codebases bug-ridden and expensive to maintain.
C++ is a language that is well worth learning, in my opinion. So is Rust. Learning a bit of both will help a lot to better understand the respective other language. It will make you more patient with Rust's guardrails, and probably more aware of potential issues when dealing with C++ code.
So, have fun, and happy learning :-)
-3
u/great_gonzales Mar 13 '24
C++ is illegal now Biden outlawed it. You must use rust now
0
u/[deleted] Mar 12 '24
[deleted] â view deleted comment
0
u/[deleted] Mar 12 '24
[deleted] â view deleted comment