More on "traits"

djberg96 on 2004-02-15T00:25:06

I read Ovid's journal recently about "traits". I hadn't heard of this concept before, nor had I heard it discussed on the Ruby mailing list, so I posted it to see what people thought about it.

A guy named David Naseby wrote an interesting response. Although an interesting topic, I think Ruby's modules/mixins do just fine without the need for traits, though traits are possible to implement if you *really* need them. I think this paragraph summed things up nicely:

... I'm still not sold on the Traits concept. I'm not sure that sprinkling methods over a distributed set of Mixins would be fun to maintain, on a large scale. The Squeak implementation took advantage of the browser: you only ever see one method at a time in Squeak (smalltalk) code, anyway, and if the browser integrates with Traits, you could view and edit the methods as "part" of the class anyway. With Ruby, without a great IDE, you'd need to flick across files and use a bit of imagination to get a good "view" of your composed class - to even see what methods it's composed of. I believe that traits lose a good deal of their appeal without the Smalltalk browser, or a great Trait-aware IDE.


traits are a poor-mans multiple inheritance

TeeJay on 2004-02-18T12:04:52

Actually they are a lighter and slightly less evil magic than multiple inheritance, but they are nonetheless designed solely to work around the limitations of a language rather than being useful in themselves.

Like much of the recently touted programming paradigms - it is only required when you are stuck in the Java or C# cage and require the flexibility of dynamic languages like perl or ruby or LISP.