Live data from Hacker News

Why does everyone here seem to dislike C++?

news.ycombinator.com

11–20 of 46 posts

Re: Why does everyone here seem to dislike C++?

#12
post #9

Apart from school, let me give you an advice. If you have a brain that can handle multiple levels of OO in c++ across multiple threads; keeping multupltformness in mind and crunching out optimized code with all that you learned in your data structure classes, stick with C++. The pay is way better (like three times more here in Toronto) than anything web or app related, the working hours are more sane, and stuff are u…

This advice is pretty spot on.. I know from really sharp C/C++ guys here in silicon valley and they are all making at least 280k a year. That's generally around double of your average backend web-dev.

Re: Why does everyone here seem to dislike C++?

#14
post #4

Compared to plain C, C++ tends to become unmaintainable. Everybody knows a tiny subset of the huge language, yet must somehow work together on a team. People do not stick to a common subset of the language that everybody is comfortable with, especially considering team members that will be hired in the future. In theory, C++ can be as fast as C. (officially lacking the "restrict" keyword, but otherwise fine) In pract…

> Compared to plain C, C++ tends to become unmaintainable...

Yeah, true. Used to think otherwise, but experience shows over and over again this happens in most large teams. C++ somewhat encourages too many abstractions and complicated control flow (exceptions, [multiple] inheritance, templates, ninja operator overloads). Building and linkage (especially against third party blobs) is also a big issue even in 2016. Builds are slow and binary incompatible between compiler versions and vendors.

> In theory, C++ can be as fast as C.

Actually, it can go both ways, C++ can be faster as well. For example when C++ enables inlining - std::sort beats idiomatic C qsort quite handily. Depends how you use it more than anything else.

Re: Why does everyone here seem to dislike C++?

#15

For an EE, C++ is a pretty good language, in that it lets you get very close to the hardware. Most of the people who criticize it don't work in that world.

> Most of the people who criticize it don't work in that world.

Huh. I've always kinda thought it is other way around. People who tend not to criticize C++ are not suffering it on a daily basis in dysfunctional organizations. :-)

Re: Why does everyone here seem to dislike C++?

#16
post #15

For an EE, C++ is a pretty good language, in that it lets you get very close to the hardware. Most of the people who criticize it don't work in that world.

> Most of the people who criticize it don't work in that world. Huh. I've always kinda thought it is other way around. People who tend not to criticize C++ are not suffering it on a daily basis in dysfunctional organizations. :-)

Yes, stupid rules can make C++ a pain. But they can do so to any language, not just C++. Don't blame the language for the organizational dysfunction. (For that matter, have you run into corporate Java?)

Re: Why does everyone here seem to dislike C++?

#17
C++ is very hard. IMO, that's why people dislike it.

I was writing a test output parser in Python: ~50 lines of functional code in less than an hour. Testing the script for about 10-20 mins and tweaking it to my liking.

The same in C++ would've required me to look up/read up a bunch of library functions that I've forgotten (Should I use file I/O, string manipulation C functions or C++ functions?), link to a few libs (non-C++11) or read some obscure documentation on C++11's regex implementation. Compile, test, change, repeat. This is way more time spent as compared to the Python option.

This is not a fair judgment of the language, but my point is that for something simple there are other languages. For something complicated, C++ has been used in many applications (successfully and unsuccessfully). But there is no doubt that once a C++ code base becomes large it is extremely hard to maintain.

Re: Why does everyone here seem to dislike C++?

#19
C++ has lots of issues, most of them due to backward compatibility and versatility. Also, the language is very complex and enormously hard to master. I've used C++ for quite a while and everybody I know who used the language for at least a few years have developed a love&hate relationship for this language, or abandoned it.

Re: Why does everyone here seem to dislike C++?

#20
To answer the titular question: I hate C++ because I worked in it for 10 years, and I came to realize things could be otherwise.

I almost came back to the language with C++11, but its core problem remains the same: the only maintainable codebases seem to be those strictly ruled over by language experts with an iron fist -- and too many people think they're experts (hint: if you haven't read the language standards (or written them!) and hacked on a compiler or two, you probably aren't an expert).

You inevitably have to choose an opinionated subset of C++, which often results in a language which is more on par with many modern languages, but with more pitfalls and traps, and which you have to teach to every person you bring on board.

And let's not even start on compile times and other problems C++'s legacy brings with it.

FWIW, I still do a lot of C and assembly. Modern C is pretty nice, although it will be nice to see a newer systems language finally take over.

You will probably end up doing C++ professionally, and that's fine, but for your own sake and the sake of your coworkers, learn some other languages that will broaden your mind.

You can find many suggestions in this thread, and I could go on about the more mind-broadening ones (logic programming, dependent types, metaprogramming, etc), but the most valuable might be another systems language, even if it's not popular, just so you can see how things could be otherwise. I think reasonable candidates might include Ada, Modula-3, Rust, D (which is a little too close to C++), BLISS if you can track down a compiler, Forth; maybe even Common Lisp.

Post reply on HN