Interfaces without implementation are like a day without sunshine

Dave Herman dherman at ccs.neu.edu
Tue Oct 24 10:03:19 PDT 2006


> overriding, then, yes, we have implemented mixins.  Using the  
> definitions you cite, interfaces << traits << mixins.  Traits remove  
> state (and in some cases overriding) from mixins, interfaces remove  
> behavior from traits.  Or, looking at it another way, traits and  

No, traits and mixins are different language features with different 
designs and trade-offs. It's not just about instance variables. Traits 
can be combined in any order, and mixins are combined in a 
programmer-specified order. This means that traits buy you convenience 
that mixins don't have: they abstract over the inheritance chain. 
Mixins, OTOH, avoid diamond import problems by forcing the programmer to 
create a total order on composition.

> interfaces take power away from the programmer in the belief that the  
> programmer will only hurt themselves.  Where does es4 want to stand?

This false dichotomy is trotted out all too often. Limiting the 
expressive power of a programming construct has many purposes, and 
"protecting novices" need not have anything to do with it.

But that's not even the issue: traits and mixins each have relative pros 
and cons. It's an active research topic, and the final word has not yet 
been written. Unfortunately, we're on a schedule and it looks like this 
one is just out of scope.

Dave



More information about the Es4-discuss mailing list