Oddbean new post about | logout
 C++ also has templates (one definition multiple types) and concepts (constrain the accepted types to have particular properties) which are all resolved at compile time. 
 templates are just complicated garbage code generators that take ages to compile, aka "generics", i have written dozens of code generators for teh same kinds of purposes and i could count the number of times it's been important on two hands in the last 8 years

interfaces achieve the same result but force you to actually think about it so the compiler doesn't have to spend many seconds trying to figure out what you mean when you refer to a method on a type that isn't explicitly tied to it

i have lost count of how many times i've used interfaces for this kind of polymorphism but it's also quite overrated, it's more useful for plugging modules together without needing to know the internals, ie, it helps with encapsulation

go has simple types of generics but only on value types, and they are actually handy a lot (especially between types of integers and between strings and byte buffers) 
 templates are just complicated garbage code generators that take ages to compile, aka "generics", i have written dozens of code generators for teh same kinds of purposes and i could count the number of times it's been important on two hands in the last 8 years

interfaces achieve the same result but force you to actually think about it so the compiler doesn't have to spend many seconds trying to figure out what you mean when you refer to a method on a type that isn't explicitly tied to it

i have lost count of how many times i've used interfaces for this kind of polymorphism but it's also quite overrated, it's more useful for plugging modules together without needing to know the internals, ie, it helps with encapsulation

go has simple types of generics but only on value types, and they are actually handy a lot (especially between types of integers and between strings and byte buffers) nostr.fmt.wiz.biz 
 here is the thing, I can't think of any situation where I would absolutely need these things, so 🤷

I guess I am a minimalist