Roles in other languages?

In a few days, I'll be giving a talk on roles at DevTank. The audience will be developers (and business people) from many different language backgrounds. I've tried assessing state of the art for roles/traits in other languages, but am falling short. I just don't know other languages/cultures well enough.

I might add that I was disappointed to learn that Scala's traits are just mixins. I wonder how they came up with that name. Surely it wasn't just misunderstanding Smalltalk traits?

Update: As preparation for the talk, I've written a short language-agnostic introduction to traits/roles. I put that on my personal blog instead of this one as I don't want people to see the blog URL and dismiss it as just a "Perl" thing.



Thanks for showing off the cross language version of roles/traits, I think it will be very useful to send around the office.


It might be worth mentioning the term aspect-oriented programming, which seems pretty close to the same idea. I first came across this idea as workable code in the Java-based Spring framework, but as far as I could tell, it was then basically a hacky and complex way around making something like this work in Java. However, the fact that it was/is a key part of Spring is a solid knock-down argument against "nobody uses it".

Leave a comment

About Ovid

user-pic Have Perl; Will Travel. Freelance Perl/Testing/Agile consultant. Photo by Warning: that site is not safe for work. The photographer is a good friend of mine, though, and it's appropriate to credit his work.