What are the consequences of allowing multiple inheritance in a programming language? Why does multiple inheritance tend to violate the very essence of OOP? Is that what differentiates a pure OOP language like Java from an OOP language like C++? Explain and illustrate.
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
closed as not a real question by Oded♦, Larry Coleman, nikie, David Thornley, ChrisF♦ Dec 2 '11 at 13:56
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.
The main consequence of multiple inheritance is the diamond problem:
In C++ the problem is solvable via virtual inheritance:
OOP languages of the single inheritance flavour provide some degree of multiple inheritance by multiple inheritance of interfaces and / or via traits / mixins (similar concepts). The diamond problem occurs in those languages too, and it's dealt with mostly language specific techniques.
Now as for Java being a "pure OOP language", that's more Sun's marketing speak (and Java fanboys speak) than truth. I've seen "OOP pureness" measured by the degree a language provides / satisfies the following criteria:
Following that "logic", Java supports primitive datatypes such as int and byte, hence less pure than let's say Smalltalk, where everything is truly an object. But measuring the "purity" of any characteristic of a language has no actual value, it's a juvenile "mine is better than yours" type of discussion.
I found this very interesting question on StackOverflow: How is Ruby more object-oriented than Python?:
The highest voted answer provides some great insight:
I've often seen Ruby cultists starting holy wars based around Matz's comments on the initial design of Ruby. As the answer I reference says: You shouldn't dismiss historical context. Something that may have been true in 1993, doesn't necessarily have to be true now. The same goes for C++ cultists referencing Bjarne Stroustrup out of context, Java cultists referencing James Gosling out of context and so on.
To add to the confusion the word "pure" has mostly positive connotations:
But in the context of programming languages, it just means homogeneous:
Having said all that, there's only one truly pure programming language.
Wikipedia has a section on Criticisms for multiple inheritance, which is as good a starting point as any. Just for reference, here are the main points:
But more importantly, you should be careful, when talking about the very essence of OOP and languages like C++ and Java. Neither of these is a pure OOP language. Take a look at languages like Smalltalk for comparison.
Another recent trend are mixins (C#) or traits (Scala), which kind of revived multiple inheritance in a way that tries to eliminate the above criticisms to some point.
This isn't an all-out answer really, which is intentional, as from your questions I sense a lack in foundational knowledge (plus the question being potentially homework). So instead I vouched to provide you with pointers on where to go for learning more about this.