Final defenders

Brian Goetz brian.goetz at oracle.com
Wed Aug 8 07:47:44 PDT 2012


And you have gotten exactly what you wished for.  That's exactly what this feature adds -- multiple inheritance of behavior.  Of course we understand that people will use them as traits.  And we've worked hard to ensure that the the model of inheritance they offer is simple and clean enough that people can get good results doing so in a broad variety of situations.  We have, at the same time, chosen not to push them beyond the boundary of what works simply and cleanly, and that leads to "aw, you didn't go far enough" reactions in some case.  But really, most of this thread seems to be grumbling that the glass is merely 98% full.  I'll take that 98% and get on with it!  

On Aug 8, 2012, at 4:19 AM, C.J. Kent wrote:

> I agree with Stephen. Interfaces with defender methods provide enough trait-like features that developers (including me) will use them as traits. It doesn't make any difference whether or not the people on this list think it's a good idea. 
> 
> I think my experience is fairly typical of corporate Java devs and I'm struggling to think of examples where the ability to evolve an interface would've been useful. But I've often wished for multiple inheritance of behaviour.
> 
> Chris
> 
> On 8 Aug 2012, at 11:56, "Stephen Colebourne" <scolebourne at joda.org> wrote:
> 
>> On 8 August 2012 11:37, Talden <talden at gmail.com> wrote:
>>> On Wed, Aug 8, 2012 at 9:49 PM, Stephen Colebourne <scolebourne at joda.org> wrote:
>>>> Where there is no doubt in my mind is that I will use traits (in
>>>> whatever form they are provided) for far, far more than interface
>>>> evolution when JDK8 is released.
>>> 
>>> This paragraph stood out to me.  The wording is important.
>> 
>> Let me reword then.
>> 
>> A new feature is being added to JDK8 - default method implementations
>> in interfaces.
>> Some are trying to state that this should only be used for interface evolution.
>> I am stating that I will use it for multiple-inheritance/trait-like
>> behaviour, far, far more than interface evolution.
>> 
>> More broadly, I'm saying that interface evolution is only occasionaly
>> an issue I face. And yes, this new feature will be useful for
>> interface evolution, but that won't be its prime use for me.
>> 
>> Having established the above, it is clear to me that it would be far
>> better to have a properly designed fuller implementation, than suffer
>> from the hamstrung API designs we will see (like the "do" method
>> prefix) without the fuller trait-like feature.
>> 
>>> It seemed that what you were really saying was "...that I will use
>>> interface default methods to implement traits far, far more...". I say
>>> that because you cannot say that you will 'use traits' when they're
>>> not on offer - you can only state an intent to use the offered
>>> features in an unintended way.
>> 
>> I'm advocating that the "unintended way"/"misuse" argument will be
>> ignored, and this feature will get used far beyond the original
>> intent. There is nothing I can see that Oracle can do to prevent that.
>> 
>> Stephen
>> 
> 
> 



More information about the lambda-dev mailing list