[E-Lang] Re: inheritance, delegation, mental models for beginners (was: down with `define' (was: newbie syntax: picayune points from a prejudiced programmer))
zooko@zooko.com
zooko@zooko.com
Sat, 03 Mar 2001 12:51:15 -0800
MarkM wrote:
> At 10:07 AM Saturday 3/3/01, zooko@zooko.com wrote:
> >I'll write more about code-reuse, delegation, sub-typing later. I'm
> >deeply interested in the topic, but right now marketing, security, and
> >syntax seem more urgent to me.
>
> Thank you for making this sacrifice. It is the right tradeoff, and I know
> you well enough to know it is a sacrifice.
Hey thanks for the encouragement!
So let's talk about inheritance and delegation from the marketing
standpoint -- assume that the programmer thinks he wants inheritance.
I can think of three strategies:
1. MarkS's "give them what they want and also give them something
better".
2. Say "we don't have inheritance, but we have delegation which is
better".
3. Say "we have inheritance, but you have to use a funny-looking
'functional programming' technique to use it". (Or perhaps: "..., but
you have to use a funny-looking bit of syntax which means nothing to
you to use it.")
I think we should (at some point -- sooner? later?) settle on exactly
one of these strategies and focus on it.
I think everyone agrees that #3 is a clear loser. (But I could be
wrong! Please feel free to let me know that I've mistaken your
position!)
The prototype for #2 would be Java including "interfaces" instead of
multiple inheritance and saying "We don't have multiple inheritance,
but we have interfaces which is better".
There are two reasons that I don't think strategy #2 will work as well
for us as it did for Java:
First, multiple inheritance was widely hated due to the C++ version of
multiple inheritance (and the perennial plague of O-O tyros using
unnecessary O-O features). Contrast with inheritance which is widely
perceived as *the* core valuable feature of O-O. (Remember we're
talking perception not reality here...)
Second, Sun prosecuted an expensive, highly organized marketing
campaign, capitalizing on the "applets in your web browser" craze and
the "freedom from Microsoft's OS" craze, to persuade millions of naive
programmers that Java was better than C++. Part of that campaign was
reiterating, and convincing their followers to reiterate, that
interfaces were a better substitute for multiple inheritance.[*] I
don't think anyone wants to spend the resources to do the same for E.
So I've just convinced myself that MarcS's "bait and switch" strategy
#1 is the right way to go.
Regards,
Zooko
[*] Disclaimer: I might have been one of those re-iterating followers
at the time. I don't remember that far back, and I did and do think
that Java interfaces can often be used where C++ would have suggested
multiple inheritance...