Inheritance vs E
shap@eros.cis.upenn.edu
shap@eros.cis.upenn.edu
Fri, 23 Oct 1998 07:45:30 -0400
> At 01:07 AM 10/23/98 -0700, you wrote:
> >So, it is clear to me that inheritance ought to be avoided as much
> >as possible when the goal is to minimize authority. The question
> >that remains has to do with whether taking inheritance out of the
> >language will make too many other things (that don't necessarily
> >require security) too inconvenient in E
>
> I think you're still missing the magnitude of the point.
I agree. While the security point is important, Ping seems to have
missed the larger point:
Inheritance creates more problems than it solves.
> Putting inheritance in a language is like baiting a trap.
Baiting a trap for developers? Who would want to? I mean, what kind
of misguided fool would actually want to *catch* one? [Insert image
of snarling, hairy, not-yet-showered developer caught in steel-jawed
trap here.] Umm. [Shapiro sniffs his monitor suspiciously and then
licks the injured paw.] Never mind.
> Jonathan has now told you that in EROS there is no inheritance.
Actually, Jonathan didn't say that. I do intend to recode in C and
eliminate inheritance, but I haven't done so yet.
Diversion on why:
EROS currently makes minor use of single inheritance in the device
driver code. What I actually needed was a common interface, not a
common inheritance tree. I thought that I needed only *one* such
interface, and inheritance at first looked like a decent way to
accomplish this.
I subsequently re-discovered that in things like bus (e.g. SCSI)
drivers one must export multiple interfaces, because the protocols
spoken by different classes of device are not compatible enough to fit
a single interface. No problem, says I to myself, I'll just capture
member function pointers and built interface structures by hand.
It proves that there is no way to capture a (member function, object)
pair. Properly designed interface mechanisms in the language can do
this.
This basically eliminated the last useful C++ leverage in the EROS
kernel, and it is my intent to recoded the kernel in C. I have not
gotten around to doing so yet.
> ... inheritance is a bad idea. Jonathan has said that he has made
> the same discovery....
I'm not sure I would go that far. Multiple inheritance is an
unmitigated disaster. I can still see cases where single inheritance
is potentially useful. I think, however, that it is worth exploring
whether interfaces (facets, if you like) provide the same advantages
with fewer problems. I suspect strongly that the answer is
``interfaces are better.''
> >I can bet that if E is presented as not having inheritance, some
> >lists of scripting languages will point out "but it has no
> >inheritance" as some sort of deficiency (i've seen such
> >feature-comparison lists) which may bother some.
Visual Basic doesn't have inheritance, but nobody gives a damn. It's
also got many times the installed base of any other scripting
language.
> Java fought the first leg of this battle when it eliminated
> multiple-inheritance. As I recall, the spat on the newsgroup lasted
> about three weeks before people were convinced that it was a bold
> and good idea.
Language design by tyranny of the netnews masses *does* seem like a
bad idea. :-)
Jonathan