Should Java have multiple inheritance? 
Author Message
 Should Java have multiple inheritance?

Quote:

> I have heard rumours that Sun is working on adding MI to Java.
> I decided to investigate with several aims:
> ...
> A few things I have learned so far:

[ Some very good condensed facts... ]

Quote:
> 3. Eiffel uses two techniques to handle name clashes from inherited
> classes: renaming and shared fields.  You don't use C++
> ICameFromClass1::myMethod style qualification.  In C++ you can handle
> inherited shared classes but not shared fields.

                   ^^^^^^^

I think you meant "methods".

Quote:
> Bertrand Meyer suggested reading : <cite>"Eiffel: The Language"
> </cite>(Prentice Hall) and the second edition of <cite>"Object
> Oriented Software Construction"</cite>, which just appeared.

This latter book is the New Testament. (Perhaps the Old Testament
was something by Wirth or somebody...)

Quote:
> More info on Eiffel: http://www.*-*-*.com/


> Canadian Mind Products    contract programming     (250) 285-2954
> POB 707 Quathiaski Cove   Quadra Island BC         Canada V0P 1N0
> http://www.*-*-*.com/ ~roedy for CMP utilities and the Java glossary
> -30-

Andrew Duncan
http://www.*-*-*.com/ ~aduncan


Tue, 02 Nov 1999 03:00:00 GMT  
 Should Java have multiple inheritance?

People with a C++ background, like myself, tend to have a rather dim view
of MI, and those with Eiffel background seem to think it is the greatest
thing since sliced bread. I have heard rumours that Sun is working on
adding MI to Java.

I decided to investigate with several aims:

1. To figure out the best way to add MI to Java if indeed it should be.

2. figure out why the difference of opinion between the camps.

3. figure out how Eiffel implements MI both from the programmer's point of
view, and under the hood.  [Bjarne Stroustrup explains much of this sort of
thing, e.g. vtbls, for C++ in his book <cite>The Design and Evolution of
C++</cite> ISBN  0-201-54330-3.  In that book he bares his soul.  You come
away with an understanding of why C++ is the way it is, including its
warts.  Surprise!  He did not want them either.]

4. to see how well MI would fit with the existing JVM.  

5. to see if Eiffel itself would be a reasonable language to generate JVM
byte codes.

Through email, quite a few people, including even Bertrand Meyer himself,
have been attempting to enlighten me.

A few things I have learned so far:

1. In Eiffel, even primitives are considered objects. This gives you
additional type safety by subclassing int.  It also lets you say things
like d.sin instead of Math.sin(d);  I think this is crucial to Eiffel's
elegant MI.

2. Eiffel dispenses with static functions and variables entirely which
simplifies the problem.  If you need them, you have to create an object for
the class.  They use a mechanism called "once" for initialisation code or
for creating only one such class object.

3. Eiffel uses two techniques to handle name clashes from inherited
classes: renaming and shared fields.  You don't use C++
ICameFromClass1::myMethod style qualification.  In C++ you can handle
inherited shared classes but not shared fields.

4. The distinction between a field and a function without arguments is very
blurred in Eiffel.

5. Eiffel compilers do many complicated optimisations to make the indirect
field-addressing, and the primitives-are-objects paradigm efficient.  These
sorts of global optimisations might well be incompatible with Java's
on-demand class loading.

6. When you add MI, it gets a little more complicated to pass a Dalmatian
object to a routine expecting a Dog, because Dog may have been inherited,
perhaps indirectly, more than once.

There is a ton of material to read, and studying this won't help pay the
rent.  I do hope though that before we set Java's MI future course SOMEBODY
has a good look at what the Eiffel people did to see what ideas could be
{*filter*}ised for Java.

Bertrand Meyer suggested reading : <cite>"Eiffel: The Language"
</cite>(Prentice Hall) and the second edition of <cite>"Object Oriented
Software Construction"</cite>, which just appeared. More info on
Eiffel-related books at   http://www.*-*-*.com/
page: http://www.*-*-*.com/


Canadian Mind Products    contract programming     (250) 285-2954
POB 707 Quathiaski Cove   Quadra Island BC         Canada V0P 1N0
http://www.*-*-*.com/ ~roedy for CMP utilities and the Java glossary
-30-



Tue, 02 Nov 1999 03:00:00 GMT  
 Should Java have multiple inheritance?

Quote:

> 3. figure out how Eiffel implements MI both from the programmer's point of
> view, and under the hood.  [Bjarne Stroustrup explains much of this sort of
> thing, e.g. vtbls, for C++ in his book <cite>The Design and Evolution of
> C++</cite> ISBN  0-201-54330-3.

An interesting book is "Compiler Design" by Wilhelm & Maurer (Addison-Wesley
ISBN 0-201-42290-5), because it's the only published reference that I know
of to the "under-the-hood" implementation of Multiple Inheritance in Eiffel.

It makes specific reference to ways to tackle the sharing of replication of
individual features in the case of multiple inheritance, and also discusses
repeated inheritance.

It's slightly dated, because it seems to address Eiffel 2.3, but it's
interesting material nonetheless.

Regards,
Roger
--
--
-- Roger Browne, 6 Bambers Walk, Wesham, PR4 3DG, UK | Ph 01772-687525
-- Everything Eiffel: http://www.eiffel.demon.co.uk/ | +44-1772-687525



Wed, 03 Nov 1999 03:00:00 GMT  
 Should Java have multiple inheritance?

Quote:

> People with a C++ background, like myself, tend to have a rather dim
> view
> of MI, and those with Eiffel background seem to think it is the
> greatest
> thing since sliced bread. I have heard rumours that Sun is working
> on
> adding MI to Java.

Can you imagine doing C or C++ with the possibility to use only once a
file the include directive!

    Richard

--
------------------------------------------------------------------
Richard Mouli   Tel: +32 2 724 17 37 (19 80)
Sony Telecom Europe (n.v.) Fax: + 32 2 726 26 86

B-1130 Brussels
------------------------------------------------------------------



Sat, 06 Nov 1999 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Multiple Dispatch (was Re: Replacing Multiple Inheritance with Java's Interfaces)

2. Replacing Multiple Inheritance with Java's Interfaces

3. Replacing Multiple Inheritance with Java's Interfaces

4. Different kind of inheritance/Multiple Inheritance

5. Having multiple languages for same application

6. VCS question: Ramifications of having multiple projects in a single subdirectory

7. Smalltalk and Multiple Inheritance

8. Free Multiple Inheritance for VisualWorks 2.0

9. Multiple inheritance

10. Multiple Inheritance

11. Is Multiple inheritance possible in VA 2.0

 

 
Powered by phpBB® Forum Software