Fork me on GitHub
#other-languages
<
2018-12-02
>
3Jane09:12:43

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.

3Jane09:12:42

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

lilactown18:12:00

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

lilactown18:12:33

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
lilactown18:12:51

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

jsa-aerial18:12:54

'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 https://github.com/jsa-aerial/hanami 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
3Jane19:12:34

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