> This is true. Java is missing something like Perl's "roles" that allow you to have code in interfaces. Imagine an "Equal" interface that defines equals and not equals. In Perl, you can provide a default implementation for not equals in terms of equals in Equals. In Java, well, I hope you like cut-n-paste or messy delegation
Scala has this feature too, as "traits". Under the cover, it does exactly what you describe with the JVM bytecode.
Of course, you can "achieve" the same feature with IntelliJ Code->Generate>Generate Delegators. You can use Yasnippets with emacs to do this and I am sure Eclipse has this feature too. While using an IDE can save the tedium of cut and paste ), it can't save the tedium of reading this code and understanding what it does (especially if you're manually mixing in multiple traits this ways).
Many good Java people are very receptive to Scala, but some tell me "my IDE can generate this, why do I need it?". They miss the point of abstraction.
Of course, that doesn't even cover abstractions that the IDE doesn't have: like pattern matching, or typeclass like abstractions with implicits, optional lazy evaluation (you can make a class called "public class LazyRef<T> { T force() { ... }}", but this is something your IDE doesn't have a "refactor button for").
Java's community has been to codify abstractions not present in Java using "design patterns" e.g., visitor pattern for multiple dispatch, delegates for traits/MI. Of course, if you want these features now you can just use other JVM languages (Clojure for MD, Scala for traits). What's interesting is that Microsoft/.NET team has been integrating these features into their "blub for the masses" (C#) e.g., Monads in LINQ despite also support distinctively non-blub languages (F#, funding Scala on the CLR).
Comments
> This is true. Java is missing something like Perl's "roles" that allow you to have code in interfaces. Imagine an "Equal" interface that defines equals and not equals. In Perl, you can provide a default implementation for not equals in terms of equals in Equals. In Java, well, I hope you like cut-n-paste or messy delegation
Scala has this feature too, as "traits". Under the cover, it does exactly what you describe with the JVM bytecode.
Of course, you can "achieve" the same feature with IntelliJ Code->Generate>Generate Delegators. You can use Yasnippets with emacs to do this and I am sure Eclipse has this feature too. While using an IDE can save the tedium of cut and paste ), it can't save the tedium of reading this code and understanding what it does (especially if you're manually mixing in multiple traits this ways).
Many good Java people are very receptive to Scala, but some tell me "my IDE can generate this, why do I need it?". They miss the point of abstraction.
Of course, that doesn't even cover abstractions that the IDE doesn't have: like pattern matching, or typeclass like abstractions with implicits, optional lazy evaluation (you can make a class called "public class LazyRef<T> { T force() { ... }}", but this is something your IDE doesn't have a "refactor button for").
Java's community has been to codify abstractions not present in Java using "design patterns" e.g., visitor pattern for multiple dispatch, delegates for traits/MI. Of course, if you want these features now you can just use other JVM languages (Clojure for MD, Scala for traits). What's interesting is that Microsoft/.NET team has been integrating these features into their "blub for the masses" (C#) e.g., Monads in LINQ despite also support distinctively non-blub languages (F#, funding Scala on the CLR).