I program in C mostly. However, it is pretty obvious that many more commercial applications are done in C++.

As far as I can tell, C++ is a very complex language, with seemingly convoluted syntax and too many constructs. C++ also encourages the abuse of Objects where structs and functions will do. In fact, the only significant advantage I see in C++ is the use of templated generic types (though, according to the developers of Go, generics are bad for programs).

Basically, my question is, did I miss something? Or is C++ more popular purely by merit of luck or marketing?

Edit: I'm sorry that I apparently asked a loaded question; in retrospect I can see that the way I worded it appears to be complete flamebait.

What I meant was, since C++ has so many different constructs and paradigms available to it, why hasn't it been replaced by languages that do less but are better at that specific thing? For instance, both Java and C# are much better suited for OOP than C++ is, while C is much simpler for system-level programming, and something like lisp is more suited for functional programming. Why is C++ used over one or more of these other languages?

closed as not constructive by gnat, Kilian Foth, BЈовић, Robert Harvey, user7043 May 19 '13 at 18:08

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    I think you're mistaken, Go's developers are considering adding generics. C++'s template system is very powerful and very complicated and much more than just generics. – jozefg May 19 '13 at 5:43
  • 6
    When contemplating ugly constructs in C++, you should probably take a minute to consider how you would solve the problems they are intended to solve, in C. You might find the results even uglier. – Carson63000 May 19 '13 at 8:09
  • 3
    @Mat: Different people are different. I thought C++ was a hideous mess before I learnt it, then I learnt it and found that in some places it wasn't as bad as I thought and in others it was worse. For "high level OOP" other languages are much cleaner (C#, Java) and for "low level non-OOP" C has less traps for the unwary (which is a scary thing given the number of "traps for the unwary" C has). – Brendan May 19 '13 at 14:22
  • 3
    This could have been a constructive question if you'd avoided the whole "C++ is ugly and complex" bit. – Robert Harvey May 19 '13 at 16:15
  • 1
    @RobertHarvey Agreed. Please see my proposed edit, which removes some loaded words. – Andres F. May 19 '13 at 17:49

Basically, my question is, did I miss something?

I believe you did, but it has less to do with programming languages and more to do with the human tendency to denigrate the unfamiliar. We do that. It's natural. Rising above it takes a willingness to endure the cognitive dissonance that comes with the comparisons to the familiar when learning something new.

You're doing two things you shouldn't:

First, you're looking at one language through the lens of another. One of the things you'll start to understand as your horizons become broader is that programming languages are just toolboxes with variations on the same set of familiar tools. The variations exist to solve specific problems. Some toolboxes contain basic tools that force you to do a lot of things yourself; others give you things to make certain complex tasks easier. My wife, who makes jewelry, has a dozen pairs of pliers that have very unusual jaws designed to solve specific problems. To me they're just funny-looking because her problems aren't mine.

Second, you're looking at every tool that's not already in your toolbox as something ripe for abuse because it doesn't fit your concept of "how it is." I have news for you: anyone with a lot of experience in a language can find a way to abuse any of its constructs. C -- and don't get me wrong here, because I've written a ton of it -- is especially rife with opportunities for abuse. Writing C is like owning a chainsaw: it's a great tool for removing unwanted limbs, but the line between use and abuse lies in whether those limbs are attached to your trees or your neighbors. Constructs that enforce better behavior are the equivalent of adding blade guards and chain brakes to chain saws: they were put there by the more-disciplined to keep them from having to clean up the messy results of the less-disciplined abusing their tools and hurting themselves or others. A little light bulb will go on above your head the first time you realize you can do a complete reimplementation of a class without having to wonder if any other code is getting away with directly writing structure fields instead of calling the setter function you so thoughtfully provided.

Or is C++ more popular purely by merit of luck or marketing?

None of the above. C++ is in wide use for the same reason as any other popular language: people have found it a useful tool for getting things done.

  • 1
    Not to detract from your answer (which has my +1), but I think C++'s merit as a useful tool wasn't the only factor. I read somewhere Stroustrup lobbied pretty hard to get key people to use C++ (even throwing hissy fits when some of his colleagues from academia criticized the language). Can't find the link now, but it was in an article/blogpost by one of his colleagues. – Andres F. May 19 '13 at 16:05
  • 1
    @AndresF. Tons of unused languages out there demonstrate that marketing efforts only makes the language being visible to companies/users, it don't make them use it. C++ is used because it's the only one that is both low and high level and focus on performance. Marketing is always a factor, but it work only on short term in engineering circles. – Klaim May 19 '13 at 18:26
  • 5
    Stroustrup also said that there are two kinds of languages: the ones people complain about and the ones nobody uses. – Blrfl May 19 '13 at 18:48
  • 1
    @AndresF. You're just giving your own feelings on this without even knowing what C++ features really are. How would you knoe someone is "a better programmer" and how would you know if features got in C++ just because he wanted it to be used? (that's actually incredibly incorrect as Stroustrup mention regularly that he was against making the language ISO at first but he did it in the end because that's what made it usable by all kinds of industry). You're just trolling without real arguments here. Also, citations from former colleagues are all but arguments. – Klaim May 20 '13 at 9:04
  • 1
    @Klaim Wait, I'm trolling because I said C++ was not adopted on technical merit alone? Wow. I mean, WOW. Someone is sensitive... – Andres F. May 20 '13 at 12:26

People want to use OOP. Also programmers want to learn as few new things as possible. Thus, when C++ first came out. It gained massive popularity thanks to backwards compatibility with C and because it implemented OOP, which was gaining massive popularity at the time. This popularity created so much momentum, that it maintains lots of it right until todays.


But todays, many better OOP languages exist and there is much less emphasis on backward C compatibility. I would reccommend looking into Java, C#, Python or Ruby for modern OOP language.


  • Ruby should definitely be in that modern section as well. – jozefg May 19 '13 at 6:01
  • 1
    @jozefg Well, Ruby is like different version of Python. – Euphoric May 19 '13 at 6:02
  • I'm gonna disagree as a Python programmer who's poked several times at ruby. But it's not really relevant anyways. – jozefg May 19 '13 at 6:04
  • 8
    OOP is the least important feature of C++. Modern C++ code is very far from the OOP principles. Just read what Stepanov, the author of STL, say about OOP – SK-logic May 19 '13 at 10:52
  • 6
    @Euphoric, do you equate classes (a pretty low-level feature) with OOP (a comprehensive design methodology and philosophy)? In STL, Boost and alike, classes are nothing but types and modules. Nothing to do with OOP. – SK-logic May 19 '13 at 11:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.