this post was submitted on 10 Feb 2026
308 points (95.6% liked)
Programmer Humor
29691 readers
1131 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
But if I have to make an Array I have to inherit from Indexable which inherits from Collection which inherits from Object! How else am I supposed to implement an Array?
Admittedly this is why I like C#'s 'implements' paradigm. Doesn't have to inherit, it just has to fulfill the contract, and then you can pass it to anything that expects the interface it implements. Keeps you from building giant trees.
As a rust developer I feel obligated by religion to make this comment:
Then you'd love rust! Rust only has "interfaces" (called traits) but doesn't have inheritance. You just have traits that don't inherit from anything and structs (that don't inherit from other structs) that implement X amount of traits.
So you can have the good things about OOP without the bad ones.
And these traits allow you to make trait objects, which would be like regular objects in C# (with vtables for the methods). If 2 different structs implement the same trait, you can "downcast" them to a trait object and store them in the same array. Or pass it is an argument to a function that wants something that implements that trait but doesn't care about the specific struct. You can of course cast it back later to the original struct.
I like interfaces as a supplement to inheritance. The strength of inheritance is getting all of the internal functionality of the parent class, while still allowing you to differentiate between children.
Interfaces are useful for disparate classes which don't have much in common besides fitting within a specific use case, rather than classes that are very similar to each other but need specific distinguishing features.
I remember some crazy stuff back when I had to work with a Java + ember.js project. Everything was like that.