logoalt Hacker News

hoshlast Wednesday at 9:59 AM1 replyview on HN

Ruby 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.


Replies

lloekilast Wednesday at 11:02 AM

Absolutely, 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.