C++ is not an object oriented language

Today I came across the video of a talk of Bjarne Stroustrup, where, among other things, he states that C++ is not an object oriented language. This contradicts what many authors write about C++, and what many people believe to know about C++. After all, C++ has classes and objects and inheritance and what no. So, it has to be an object oriented language, right? It’s not that simple.

What does “object oriented language” mean?

It depends largely on the definition of an object oriented language. If you define an object oriented language as a language that provides the possibility to do object oriented programming, then C++ is an object oriented language.

But, then, depending on what features you define to be essential for object oriented programming, C is an object oriented language as well. I have seen C-code that had something resembling constructors, methods, virtual function tables and so on.

However, if you define an object oriented language as a language that enforces object oriented programming, where you put everything in a class, and that provides lots of features that make object oriented programming an easy task, then C++ is not an object oriented language.

Comparing C++ with object oriented languages

With that in mind, we may be able to understand some people who come from Java or C# and consider C++ a bad language: They expect an object oriented language with all its cozy features like e.g. a garbage collector and are disappointed because they don’t get what the brochure promised.

It even might not matter to them that C++ has to offer more than just the possibility of object oriented programming – which is one of its strengths – because they don’t know or don’t care about those other features.

So, for people who want to build an application in a purely object oriented way, one should not advertise C++ as the language to use, because it might not be. C++ is not a purely object oriented language, and if you are in need of such a language, it is not a bad language, it is simply the wrong language.

If not object oriented, what is it?

So where does that leave C++? It’s not a object oriented language, although you can do object oriented programming with it. It is not a procedural language, although C is a subset. It’s not low level, because it provides higher level abstractions, but you can twiddle bits and fool around in memory directly, if you have to.

C++ provides features for generic programming, includes a Turing complete compile time (meta-)programming language and you can even do functional programming and actor based programming if you are crazy enough.

For all this, C++ is called a multi paradigm language. You can do almost everything with it, if you have or want to, but it is not the best language for everything. C++ is a tool among many, and it is the programmer’s task to choose the right tool to solve his problem. It is also his duty to know how to wield the tool, i.e. do know when to use the object oriented or procedural or generic facets of C++.

This multiplicity may make C++ harder to learn than other languages, but it can also make it so much more fun to have all the possibilities at your fingertips, once you know when and how to use and combine them.

Previous Post
Next Post
Facebooktwittergoogle_plusredditlinkedinFacebooktwittergoogle_plusredditlinkedinby feather

6 Comments



  1. People may want to use C++ even if they are planning to predominantly use OO techniques if they really care about performance. In fact, the choice to use C++ over Java/C# is usually driven by performance, not by the available paradigms.

    C is not OO in any way because it does not provide any built in language support for OO. C++ is a multi-paradigmatic language supporting OO as one of its paradigms, like e.g. python. I think this is well understood and it’s not necessary to logic chop.

    Reply

  2. The fun part about C++ is the flexibility permitting paradigm jockeying. See the analogy with DJ/VJing? Otherwise multi-paradigm languages have to justify that paradigms aren’t mutually exclusive, eg. http://www.quora.com/What-exactly-is-the-difference-between-the-dataflow-and-behavioral-paradigms-in-VHDL
    As Qt’s MOC is predominant over CopperSpice or C++/CX over Kenny Kerr’s moderncpp, … it’s tough for practitioners to advent at par with standardization folks.
    PERL6 does paradigm jockeying too! But when native performance is wished, C++ wins.

    Reply

    1. Thanks for your thoughts Vipul. I don’t know Perl6, but I agree that the possibility to use multiple paradigms together are a strength of C++ but also a reason for its steep learning curve.

      Reply

  3. thanks for putting light on that specious thought. I wrote same on my POPL essay, instructor turn me down with zero, Now i can pitch in!!
    Just to clarify , if C++ has to be OO Language presence of floating functions and so as “main” is forbidden right?

    Reply

    1. Hi Mahesh, it depends on who you ask, but yes, I think for many a language with free functions is “not fully OO”

      Reply

Leave a Reply to Mahesh Cancel reply