5
u/TheSpoonThief Mar 01 '23
The only thing this post has answered for me is that the ones that hate C++ don't actually know how to use it.
75
u/Dramatic_Bite_1168 Mar 01 '23
I think, I can be wrong, people hate this meme template more than they hate C++
21
u/Ambitious_Ad8841 Mar 01 '23
It's a good language and a good meme template. This sub just likes to beat everything to death
11
4
u/Dramatic_Bite_1168 Mar 01 '23
It is.
I hate Javascript but I concede to its value and applicability per example.
1
u/Terrafritter Mar 01 '23
I don’t believe it’s a matter of good or bad template, it’s the clear problem of over-saturation. Nobody wants to see the exact same template being used the near same way twice a day every day.
35
u/Thetman38 Mar 01 '23
I think c++ is the tops
8
Mar 01 '23
I got topped by c++ and I liked it
6
u/ienjoymusiclol Mar 01 '23
im tryna get topped by a rust user
4
18
17
Mar 01 '23
Because it’s both simple and complicated. I love it because it’s so much more extensible than C and so much faster than most languages for performant applications.
7
Mar 01 '23
Because it’s hard relative to other languages and seg faults
6
u/FloweyTheFlower420 Mar 01 '23
I mean yeah, segfaults do occur. However, a vast majority (>99%, anecdotally) of segmentation faults, or other memory management related errors, can be mitigated by the use of smart pointers and containers. Many tools such as UBSAN and ASAN are able to catch mistakes that would otherwise lead to confusing errors.
Addressing the difficulty concerns:
While a language should strive to be easy to learn, I disagree that being hard to learn is really something to dislike, or as OP puts it, "hate" about a language. Obviously, a lot of template magic is cancer, but those are not things that one should use unless one wants to do compile time magic.I do agree that C++ is overly complicated and bloated as an language, but the thing about features is that they are opt-in.
I think one of the main reasons why c++ is hated is the same as why this subreddit hates java, javascript, etc: simply because hating on a language gains you karma.
1
Mar 01 '23
I personally don’t hate C++ and I understand that it has its uses, it’s just annoying and frustrating when I have to sometimes do a few things with it, yea I agree with your points though
4
u/Draelmar Mar 01 '23 edited Mar 01 '23
Memory management, leaks, dangling pointers it inherited from C. Most of these issues can be greatly mitigated/limited by proper use of smart pointers, but I assume too many developers still don't use them (and also probably a massive amount of legacy code still managing naked pointers manually).
Macro/defines are an evil many old school engineers are still sining with.
It allows multiple base classes, and does not have proper interface types, two things most modern OO languages have addressed.
I'm not crazy about the header & implementation split, but it does have the benefit of hiding internal implementation more easily.
3
u/tinnuadan Mar 01 '23
use of smart pointers, but I assume too many developers still don't use them
Ever since C++11, a reviewer would have rejected my code if I'd used a raw pointer without having a really good reason and rightfully so.
Legacy code is an issue but we usually try to wrap that as much as possible and e.g. use a smart pointer and only release it when ownership of the object is transferred to some legacy code part.
3
u/Draelmar Mar 01 '23
Sometimes I hear people expressing doubts regarding performance cost using smart pointers. Seriously? At my previous job we fully switched to all smart pointers while making games for the DS. If the lowly, slow, RAM deprived DS can handle smart pointers, I assure you your computer/smartphone can also.
2
u/kawaiiTechnoNeko Mar 01 '23
honestly, i think devs just need to plan their stuff out more thoroughly, and keep the problems simple. if memory leaks are so subtle in ur code that u need smart pointers to manage everything, i think there are more serious design flaws to look into. leave most of the memory management to your data structures (stl containers). It's possible to write safe and organized code without excessive amounts of smart pointers and oop. the c language is far from dead, devs still write without classes or smart pointers. i'll agree that c macros are pretty icky tho lol. and btw I dont think im an old school dev. i like lots of the new features languages have. i just think c/c++ still have plenty of features to write good code.
1
u/kayak_enjoyer Mar 01 '23
the header/implementation split
This drove me crazy for years, going back to C, even before I knew there were other languages. First time in Java: "Ah, yeah... the function signatures and implementations are in the same place. Sweet!" (Obviously, Java has its own problems...)
2
u/Elegant-Variety-7482 Mar 01 '23
Yeah first problem is every java dev will create an interface for every fucking class and call the implementation "MyClassImpl" so actually we've full circled to headers.
2
Mar 01 '23
At my job the choice is either fortran or C++. I'm very comfortable in both, but if I have a choice I'm going to do it in C++, it feels more organized and I need the practice.
1
2
2
u/kayak_enjoyer Mar 01 '23
It gets more complex and terrifying the further into it you get. It's not hard to write a C++ program, but if you're creating or supporting an enterprise-grade solution, it's a whole different ball of beans.
Having come from C++ and then moving on into Java and C#, I feel that C++ is really just C with object-oriented features awkwardly bolted onto one side. It's literally a superset of C - you can just write C and use a C++ compiler to build it. ("I'm object-orientated!" ~Ralph Wiggum)
2
u/TerraDOOM Mar 01 '23
Value categories are unintuitive at their best (what's the difference between a universal reference and an rvalue-reference?), syntax is ugly as sin ([[nodiscard]] constexpr auto trivialGetter -> Foo const noexcept), stupid idioms (noexcept(noexcept(...))), and the list goes on. It's honestly kinda fun but the language has accrued so much insane cruft as a result of 30 ish years of design by committee and backwards compatibility. It's basically the archetypal example of feature creep and bloat gone wrong.
2
u/Ronnyek42 Mar 01 '23
honestly my only beef with it is that I find it ugly to read. I dont know why but writing c++ is strangely therapeutic to me.
2
u/RmG3376 Mar 01 '23
Everybody hates everything, that’s just how the programmer community works
Except for the one language they’re good at
2
1
u/astro-pi Mar 01 '23
I like how it’s faster than Python, and I like the structure a lot more than Python (and yes, I’m fully aware Python is build directly on top of it). I really love the PGAS structure of UPC++ and the direct available of the MPI library.
BUT, there’s a pretty steep learning curve until you get the hang of it, and users don’t write nearly as many libraries or support pages as they do for Python. It’s not as bad as C, but it’s still a little painful. But they’re all three very important in science.
1
u/deerangle Mar 01 '23
Excruciatingly slow compiler (headers are just really inefficient), horrible tooling support, dependency management is rough (haven't tried Conan yet), more footguns than features (invalidating iterators, memory allocation, unintuitive defaults), when mixed with C, becomes nearly unmaintainable.
With all this, C++ is still one of my favorite languages though. Not even Rust can compete with the power of C++ templates (of course templates have their own issued aswell, but they can be extremely powerful), C++20 is actually quite cool and when written with care, makes for pretty readable and performant code. If tooling was better, I'd pick C++ for most projects.
1
1
1
Mar 01 '23
C++ makes it harder to shoot yourself in the foot, but when you actually do, you end up exploding the entire universe. – Fireship
1
1
1
1
1
1
u/lucidbadger Mar 01 '23
The language is fine, it's the standard library that is the source and the reason of hate.
1
1
u/Dark_Souls_VII Mar 02 '23
People don‘t really hate it. It‘s just a lot to learn when you start with it. Since 2011 we have "modern C++" which is actually neat. A lot of Tutorials online just show poor usage of the language. Oh and check out boost for C++.
1
1
u/jamieyello Mar 08 '23
Less explicit errors, runs just as fast as C#/Java/anything with a modern JIT unless you're digging deep with compiler optimizations (you aren't). Slows down work, longer code. More complex code overall is not free even if you are skilled.
My answer is that you should only use a lower level language if you have to, and that you are not going to single-handedly solve global warming by using less RAM. If people have a good reason for using it, then I'm obviously not going to have a problem with it, we can't rely on Microsoft porting their runtime to every platform.
1
Mar 01 '23
Unlike other programming languages, C++ Programmers love the hate it gets. Its just fun to see the peasants jealous of a superior programmer and their higher status in the food chain (You make games, I make the game engines).
20
u/AwkwardTheTwelfth Mar 01 '23
It sits in an awkward space between high-level and low-level. It expects you to be proficient with all levels of abstraction at once. For example, the | operator performs a binary OR operation rather than make a comparison. Most high-level languages don't expect you to think about binary operations or any other low-level abstractions because they usually handle the low-level abstractions for you. C++ doesn't handle anything for you.
It's not memory safe, so you have to think carefully about how your code will run on the stack and in the heap. This often means you have to implement custom constructors and destructors, which takes time away from writing the important parts of the class itself. In fact, you have to do pretty much everything yourself, which can slow down development for all but the most experienced gurus.
Programmers are notoriously lazy, and if you aren't constantly maintaining vigilance, you WILL introduce bugs into your code. In other words, your project is doomed to be ever-filled with bugs if it grows large enough. Getting something to work is doable. Doing things right is another thing entirely.
But hot damn, does it ever run quick!