Fork me on GitHub

Calling it “solving copy paste problems” is kinda dismissive. Rather, they are a solution used for different problems; and the one I saw them used the most for was an insufficiently expressive yet rigid type system which forced people to copy paste code.


(The ability to specify covariant return type / contravariant argument type helps with it.)


I didn’t mean for it to be dismissive, though I see how it can be interpreted that way in hindsight


I think that solving “copy + paste problems” is very noble. I was trying to put it in terms that might be easier to understand if someone didn’t know much about type systems

☝️ 4

I guess a better explanation might be: Templates/Generics solve the problem, “I want this implementation to be used with many different types (in a statically typed language).” Interfaces solve the problem, “I want to communicate to other developers that if they want to use this implementation, they must also implement this other API themselves.”


'Generics' may be more or less tied to types, but 'templates' are more general than that. (I put both in quotes, because there can be many different takes/definitions). For example, the template system in has nothing to do with 'types' and a whole lot to do with abstracting away from a need to 'copy/paste'. Macros would be another example.

💯 4

Sure; given they were grouped with generics however I assumed we were talking about types. Is cool.