r/programming • • Oct 11 '26

I don't like interfaces

https://codestyleandtaste.com/don't-like-interfaces.html
0 Upvotes

40 comments sorted by

View all comments

1

u/kuikuilla Oct 12 '26

Declare capabilities such as clonable, comparable, and more

All of which is stupid.

Why? How else would you do that? Would you rather make specialized functions for all kinds of "comparable" things and have function overloading handle the rest? How would that work when someone creates a new "comparable" thing without having access to the compare et. al. function source? How would they get it supported?

1

u/levodelellis Oct 12 '26

Did you read it out of order? I mentioned those specifically are fine but unnecessary in an interface. I know some language force you to inherit/implement an interface and put compare/other code there, which IMO is fine. But I don't think I ever wanted to compare two abstract types unless maybe it was to check if the instance is the same. But I really don't think anyone should create an IMyCompare and have everything implement it through that. It's just silly

In systems languages I use operator overloading (or if it has to be C) a compare function if memcmp won't work (it has pointers). I never need a virtual func, or to do it with a base type