Re:Inheritance was invented as a performance hack
by rst on Friday April 30, 2021 @09:37AM
(#26993282)
... which does put both cars and bicycles in the same queue, but doesn't eliminate the copy-paste for each new type completely; 'car' and 'bicycle' still wind up with separate 'get_speed' impls, which are textually identical aside from the type names.
[ Parent
| on HN ]
Re:Inheritance was invented as a performance hack
by Tyr42 on Friday April 30, 2021 @12:14PM
(#26995375)
Sure, traits talk about functions, not properties/ strict fields, so you need to provide trivial getters if you want to abstract over properties.
True, but not that interesting? Sure we could have some Ruby :get_attrs magic or whatever.