Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > multiple inheritance

Reply
Thread Tools

multiple inheritance

 
 
bob smith
Guest
Posts: n/a
 
      08-04-2012
From: "bob smith" <bob.smith@1:261/38.remove-5qr-this>

From: "bob smith" <bob.smith@1:261/38.remove-yy0-this>

From: "bob smith" <bob.smith@1:261/38.remove-s5y-this>

From: bob smith <(E-Mail Removed)>

Why doesn't Java support multiple inheritance?

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      08-04-2012
To: bob smith
From: "Eric Sosman" <eric.sosman@1:261/38.remove-5qr-this>

To: bob smith
From: "Eric Sosman" <eric.sosman@1:261/38.remove-yy0-this>

To: bob smith
From: "Eric Sosman" <eric.sosman@1:261/38.remove-s5y-this>

To: bob smith
From: Eric Sosman <(E-Mail Removed)>

On 8/1/2012 10:28 PM, bob smith wrote:
> Why doesn't Java support multiple inheritance?


To discourage formation of a Kennefeller dynasty?

Because diamonds are a girl's best friend but a programmer's
biggest headache?

The web is full of pages discussing the pros and cons of
Java's choice. Perhaps you should read a few of them and then (if so moved)
post "Excuse E for omitting multiple inheritance seems unconvincing to me for
reasons R1 and R2, despite supporting arguments S1 through S9. Here's a
concrete example where I think R1 and R2 trump S* and overturn E; what do
others think?"

--
Eric Sosman
http://www.velocityreviews.com/forums/(E-Mail Removed)d

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
 
 
 
markspace
Guest
Posts: n/a
 
      08-04-2012
To: bob smith
From: "markspace" <markspace@1:261/38.remove-5qr-this>

To: bob smith
From: "markspace" <markspace@1:261/38.remove-yy0-this>

To: bob smith
From: "markspace" <markspace@1:261/38.remove-s5y-this>

To: bob smith
From: markspace <-@.>

On 8/1/2012 7:28 PM, bob smith wrote:
> Why doesn't Java support multiple inheritance?
>


The diamond problem. I'm not really up on the details however.

I can tell you from hanging out on the lambda-dev list (Java 8 features) that
Brian Goetz has pushed back strongly on any sort of multiple inheritance.
Apparently the diamond problem is a real bear and introduces real complexity
into both the compiler and the user code that can cause big problems in the
long run.

http://en.wikipedia.org/wiki/Diamond_problem

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
Joshua Cranmer
Guest
Posts: n/a
 
      08-04-2012
To: bob smith
From: "Joshua Cranmer" <joshua.cranmer@1:261/38.remove-5qr-this>

To: bob smith
From: "Joshua Cranmer" <joshua.cranmer@1:261/38.remove-yy0-this>

To: bob smith
From: "Joshua Cranmer" <joshua.cranmer@1:261/38.remove-s5y-this>

To: bob smith
From: Joshua Cranmer <(E-Mail Removed)>

On 8/1/2012 10:28 PM, bob smith wrote:
> Why doesn't Java support multiple inheritance?


Because multiple inheritance is really, really, really complicated and
confusing for most users.

The short answer is the diamond problem:

class A { int varA; };
class B : A { int varB; };
class C : A { int varC; };
class D : B, C { int varD; };

There are two main points of contention in this kind of hierarchy: 1. How many
copies of varA should D have? Intuitively, one is probably what most people
would expect, but the implementations of B and C would have to cooperate in
realizing that their superclass may be shared with D. It also incurs a penalty
in runtime costs 2. How does initialization/override order get resolved? Is it
"BFS"-y (like D, B, C, A) or "DFS"-y (D, B, A, C)? There are even more
convoluted orders in practice (C3 appears to be the most common nowadays), but
this is the sort of stuff that tends to cause nasty sorts of little edge cases
in practice.

It is rare in practice that you need true multiple inheritance, in the sense of
inheritance of implementation; multiple inheritance of interface is common, and
this is as far as Java goes.

--
Beware of bugs in the above code; I have only proved it correct, not tried it.
-- Donald E. Knuth

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
Gene Wirchenko
Guest
Posts: n/a
 
      08-04-2012
To: markspace
From: "Gene Wirchenko" <gene.wirchenko@1:261/38.remove-5qr-this>

To: markspace
From: "Gene Wirchenko" <gene.wirchenko@1:261/38.remove-yy0-this>

To: markspace
From: "Gene Wirchenko" <gene.wirchenko@1:261/38.remove-s5y-this>

To: markspace
From: Gene Wirchenko <(E-Mail Removed)>

On Wed, 01 Aug 2012 20:07:58 -0700, markspace <-@.> wrote:

>On 8/1/2012 7:28 PM, bob smith wrote:
>> Why doesn't Java support multiple inheritance?


>The diamond problem. I'm not really up on the details however.


Such a lovely name. The link does go into enough detail to
understand it.

>I can tell you from hanging out on the lambda-dev list (Java 8 features)
>that Brian Goetz has pushed back strongly on any sort of multiple
>inheritance. Apparently the diamond problem is a real bear and
>introduces real complexity into both the compiler and the user code that
>can cause big problems in the long run.
>
>http://en.wikipedia.org/wiki/Diamond_problem


It also has a number of different handlings in MI languages so
there is not an obvious solution.

Sincerely,

Gene Wirchenko

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      08-04-2012
To: Joshua Cranmer
From: "Lew" <lew@1:261/38.remove-5qr-this>

To: Joshua Cranmer
From: "Lew" <lew@1:261/38.remove-yy0-this>

To: Joshua Cranmer
From: "Lew" <lew@1:261/38.remove-s5y-this>

To: Joshua Cranmer
From: Lew <(E-Mail Removed)>

Joshua Cranmer wrote:
> bob smith wrote:
>> Why doesn't Java support multiple inheritance?


Strictly speaking, Java does support multiple inheritance, just not from
classes.

This is because multiple inheritance of implementation is silly.

> Because multiple inheritance is really, really, really complicated and
> confusing for most users.
>
> The short answer is the diamond problem:
>
> class A { int varA; };
>
> class B : A { int varB; };
>
> class C : A { int varC; };
>
> class D : B, C { int varD; };
>
> There are two main points of contention in this kind of hierarchy:
>
> 1. How many copies of varA should D have? Intuitively, one is probably
>
> what most people would expect, but the implementations of B and C would
>
> have to cooperate in realizing that their superclass may be shared with
>
> D. It also incurs a penalty in runtime costs
>
> 2. How does initialization/override order get resolved? Is it "BFS"-y
>
> (like D, B, C, A) or "DFS"-y (D, B, A, C)? There are even more
> convoluted orders in practice (C3 appears to be the most common
> nowadays), but this is the sort of stuff that tends to cause nasty sorts
> of little edge cases in practice.
>
> It is rare in practice that you need true multiple inheritance, in the
> sense of inheritance of implementation; multiple inheritance of
> interface is common, and this is as far as Java goes.


Quite so.

--
Lew

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

-+- BBBS/Li6 v4.10 Dada-1
+ Origin: Prism bbs (1:261/3
-+- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24

--- BBBS/Li6 v4.10 Dada-1
* Origin: Prism bbs (1:261/3
--- Synchronet 3.16a-Win32 NewsLink 1.98
Time Warp of the Future BBS - telnet://time.synchro.net:24
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
inheritance, multiple inheritance and the weaklist and instance dictionaries Rouslan Korneychuk Python 8 02-10-2011 04:02 AM
Interface inheritance vs Implementation inheritance. Daniel Pitts Java 27 02-27-2008 01:37 AM
Private Inheritance and Publice Inheritance karthikbalaguru C++ 9 09-10-2007 01:05 PM
mul. inheritance & overloading operator new/delete solved by virtual base inheritance? cppsks C++ 0 10-27-2004 07:49 PM
Private access modifier and Inheritance (Inheritance implementation in Java) maxw_cc Java 1 12-21-2003 11:38 AM



Advertisments