Multiple inheritance in Java/C#

Michele Simionato michele.simionato at
Wed Nov 19 19:18:09 CET 2003

hungjunglu at (Hung Jung Lu) wrote in message news:<8ef9bea6.0311182031.38034c10 at>...
> Hi,
> I think Microsoft did look into Python when they designed C#. (E.g.
> they got rid of checked exceptions of Java.) However, they followed
> Java in avoiding multiple inheritance (MI), which is a great leap
> backward from C++, in my opinion. I understand the why of avoiding
> virtual data members, since performance is an issue. I understand the
> problems of MI in C++. But the cure (using interfaces) seems worse
> than the disease itself. Now if you change an interface, you have to
> go and change all classes that use the interface. For Java, this is
> discussed in:
> Standard reply is a cold sholder: "interfaces are not meant to be
> changed". But we live in the real world. Also, I don't think it is fun
> to write zillions of getters/setters, and wrappers for implementing
> interface methods in MI of interfaces. Sure, you can have the IDE
> writing some of these codes, but that brings other sets of problems,
> too.
> Python of course is free from these problems. To start with, Python
> data members are virtual, easily overridable. I remember people used
> to complain that Python does not support encapsulation and that
> private data in inheritance chain could be overriden. But that
> actually is GOOD in many cases, and especially in MI a la MixIn.
> Does anyone know how to emulate Python-like MI in Java/C#?
> regards,
> Hung Jung

Yeah, I am not convinced at all by the interfaces strategy; if not
real multiple inheritance, they could at least have provided something
along the way of Ruby's mixins.

About implementing Python MI in Java/C#: in principle you could do it
yourself, by following the MRO algorithm described in

In practice, I do expect to implement MI properly to be cumbersome
and with a (possibly high) performance price.

A good idea is to ask Jython developers.

               Michele Simionato

More information about the Python-list mailing list