5 ms·
Does Ruby have traits ? http://pharo.gemtalksystems.com/book/LanguageAndLibraries/Traits/ http://pharo.gemtalksystems.com/book/LanguageAndLibraries/Tr...
by kilon 13y ago
Does Ruby have traits ?
http://pharo.gemtalksystems.com/book/LanguageAndLibraries/Traits/ http://pharo.gemtalksystems.com/book/LanguageAndLibraries/Tr...
- nnq 13y agoWell, isn't the use case for traits the same as for mixins? (http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_modules.html#S2 http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_module...)
- kilon 13y agoyeap definitely looks like it. I would not be surprised if Python has something similar too. For me OO is not the big reason to use smalltalk. For me the biggest reason is the whole live coding environment which is a big plus for workflow and speed of development. But maybe other smalltalkers could chime in with features I am not aware of. Also Pharo has Pooldictionaries , which are doing the same thing Traits are doing for methods , for instance variables. Probably Ruby has something similar too. I really think highly of Ruby , its a really powerful language. The reason why I chose python instead is that I can't stand the "Pearl" syntax. All these weird symbols etc. Definitely not my thing and make code less readable to me. But as a language Ruby looks great to me. So definitely would not recommend against learning it :)
- nnq 13y agoPython has good multiple inheritance and as far as I've seen most sane people just use it to "emulate" mixins and even name their secondary parent classes like Feature1Mixin or DoesYTrait. Traits seem like a great idea, but the only other language where I've seen it under the Smalltalk name of "trait" is... brace yourself :) ...PHP 5.4+.
- seanmcdirmid 13y agoScala has traits, to great effect.
- spooneybarger 13y agoThere are a few subtle, important differences... Check out the original paper and they should become apparent: http://web.cecs.pdx.edu/~black/publications/TR_CSE_02-013.pdf http://web.cecs.pdx.edu/~black/publications/TR_CSE_02-013.pd...