Extension methods vs. Traits
Mark Reinhold
mr at sun.com
Tue Dec 15 22:21:44 PST 2009
> Date: Fri, 11 Dec 2009 10:45:19 +0100
> From: daniel.latremoliere at gmail.com
> I would like to understand the final paragraph of the proposal where you are
> saying that the traits are much more significant change than extension methods
> to the language and VM.
>
> ...
>From a strictly technical standpoint adding traits might not be a (much?)
more significant change than adding extension methods.
>From a conceptual standpoint, however, adding traits to the language is
a hugely significant change -- much more significant than adding lambda
expressions.
If we add traits to the language then every Java programmer will, sooner
or later, need to learn how to read and compose them, and traits are very
different beasts from the classes and interfaces with which we're all so
familiar today. (Extension methods, by contrast, are just a fancy new
variant of static imports.)
Traits have worked out reasonably well in Scala, and in the long term
it's worth considering adding them to Java, but now is not the right
time. They're worth thinking about now, however: If traits really are
a better way to achieve the goals addressed by extension methods then
perhaps we should drop extension methods in this release and take up
traits in the next.
- Mark
More information about the lambda-dev
mailing list