Multiple inheritance in Java/C#

Hung Jung Lu hungjunglu at yahoo.com
Tue Nov 18 23:31:35 EST 2003


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:

http://www.cyberdyne-object-sys.com/oofaq2/DynInh.htm

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




More information about the Python-list mailing list