7 ms·
I've recently started working in C++ (I've had some prior knowledge, but mostly basics) and whenever I try to Google stuff up, a few of the results are Don't us
by spoiler 13y ago
I've recently started working in C++ (I've had some prior knowledge, but mostly basics) and whenever I try to Google stuff up, a few of the results are Don't use C++ because of X
I read a few of them out of curiosity, and realised that they are mostly religious reasons to hate C++, hardly any of them are proper, factual, or empirical reasons. So, my hypothesis is the following: They were unable to learn C++, and because of immaturity, decided it was stupid[0][1].
[0]: I'm no saint to this. I said on numerous occasions Erlang is shit because I couldn't wrap my head around the syntax.
[1]: I believe it's a phenomenon associated with Psychological Projection, but I might've confused it with something else.
- lucian1900 13y agoThere are good arguments against C++, but they resume to its extreme complexity and lack of extra safety compared to C. Both are fair points and why I avoid it.
- Ragnarork 13y agoWhat do you mean by "Lack of extra safety compared to C"? I'd have imagined the exact opposite, but maybe I'm missing something there.
- pjmlp 13y agoC++ is way safer than C thanks to stronger type checking and what you can achieve via library types like STL collections. However the C unsafety is still present due to the compatibility compromises with C in C++'s design. With teams it is very hard to control what each developer makes use of, even with static analysis.
- Ragnarork 13y agoThat was kind of my point. I really think that if anything, C++ cannot be as unsafe as C. You can do crap in C++ just as well as you can do in C, but at least C++ gives you tools to do things way more safely IMO.
- pjmlp 13y agoYes, that is one reason why I never liked C, but do enjoy C++ for personal projects or when everyone on the team is quite comfortable with it. For the other type of enterprise projects I rather use languages that follow Algol linage of memory safety.
- lholden 13y agoI consider modern C++ to be a lot safer than C. Between RAII, copy, and move schematics the pointer use has gone down quite a bit. When you do use pointers, we finally have a real null pointer literal now. (I believe the latest C spec has also received this.) C++ is certainly crufty. The language has been around for a long time and many features in the specification exist to support legacy code. This is a side effect of being a living language with a huge user base. Modern C++ tends to be fairly clean and reasonably easy to work in. Herb Sutter has some great talks and blog articles around the topic. For example: http://channel9.msdn.com/Events/Build/2014/2-661 http://channel9.msdn.com/Events/Build/2014/2-661
- azth 13y agoI think it is somewhat telling that even gcc switched to C++.
- k00pa 13y agoI have seen people giving up on C++ without actually even trying to learn it. Somehow all these pointers are "scary" and "hard". And people are usually trying to learn C++ the wrong way. (Lets download this big library/framework and figure out by doing)
- TillE 13y agoC++ isn't the easiest language to work with, but what I find truly bizarre are all the internet people who apparently hate C++ while also praising C as wonderful and "elegant". I'm convinced that the vast majority of them have never written anything significant in C, which is a painful experience tolerated only by systems programmers who actually need something that's one step above a portable assembly language. C++ only fails if you try to write it like C, and don't take advantage of all the lovely new tools it gives you. It's always been a more useful language for nontrivial projects, and C++11 elevates it so much further.
- pjmlp 13y agoYes, many fail to understand that most C++ warts are caused by its C compatibility and are actually C issues. Which incidentally also affect Objective-C for the same reasons.
- nitrogen 13y agoDear HN, Is it really necessary to start another language war thread? Sincerely, a happy C developer.
- pjmlp 13y agoI am not starting a another language war. Just stating the fact that when someone posts "C++ is horrible because of X", that X is either also available in "ANSI C", caused by compatibility with C semantics or compatibility with C toolchain.
- nitrogen 13y agoHow about this one: "C++ is horrible because of implicit copy constructors"? That one's not in C :-). The newest additions to C++ for functional programming and automatic typing are quite intriguing. Blaming everything wrong with C++ on C is as disingenuous as labeling everything about C++ as wrong because one thing about it is wrong.
- mattgreenrocks 13y agoMost Internet hivemind (euphemistically called "conventional wisdom") behavior is more about belonging and less about discussing truth. It's similar to the rants about Perl's ugliness: it's up to the programmer to make it readable. C++ can be a perilous language, but it affords a surprising amount of expressive power with a very low performance overhead. It requires you to be focused and think clearly about things like object lifetimes. It rewards thinking hard ahead of time to simply jumping in, writing code, and debugging it until it works.