Sun 16 Aug 2009
Mixins are a very useful feature of languages like Ruby that help you make small reusable bits of functionality. A few people have tried to implement mixins in Java:
- JAMIE (pdf link) is a preprocessor that adds mixins through automated delegation.
- AspectJ is a whole new language that extends the Java syntax and adds mixins as well as a large number of other features.
- Eclipse adaptors (pdf link) are a different solution to the same problem that mixins address.
Of those three projects, the one I like most is JAMIE, but it modifies the java language and requires a code proprocessor.
Mixins For Java is a library I’ve created that implements mixins through automated delegation using annotations and generics.
I’ve recorded a screencast that shows the library in action:
Click here to view the Mixins for Java screencast
The code is available from code.google.com/p/java-mixins