4 ms·
Can't help but wonder if that isn't more the fault of Java's OOP design. Favoring composition over inheritance doesn't seem like something Smalltalkers and Ruby
by goatlover 10mo ago
Can't help but wonder if that isn't more the fault of Java's OOP design. Favoring composition over inheritance doesn't seem like something Smalltalkers and Rubyists had to worry as much about.
- misja111 10mo agoIt was definitely also a fault of initial OOP in Java. Java's interfaces became a bit more flexible later on.
- wk_end 10mo agoWhat's this referring to?
- ch_123 10mo agoThe GoF book predates Java, and many of the examples in the book are in Smalltalk - so I think it's quite likely that composition over inheritance came from the Smalltalk community. Problems with inheritance, such as the fragile base case problem, are intrinsic to inheritance, and not any specific language's implementation of it.
- hosh 10mo agoRuby does have language features for composition, and “composition over inheritance” has popped up in the community. I have also looked into the use of traits in Smalltalk.
- lloeki 10mo agoAbsolutely, usage of inheritance is (comparatively to Java/C++/Python) quite rare in Ruby. People favour modules to compose (e.g Enumerable), and more generally interfaces (e.g duck-typed StringIO vs IO/File/etc...) If you throw in RBS and start to type Ruby things then you start to see that Go-style interfaces pop up quite frequently.