|
|
|
|
|
by tome
2117 days ago
|
|
Subclass polymorphism in typical OO languages (Java, C++, Python) is nothing like type class polymorphism. Class inheritance is nothing like type class sub/superclassing. It's quite possible for one to be good and the other to be bad (and I would claim that is indeed the case). |
|
I believe in OO this concept comes from Self from 1987, where they first implemented Traits. In Standard ML TypeClasses were introduced in 1988 I believe. So it actually seems that OO would have had a form of ad-hoc polymorphism before ML. Now I don't want to debate where the ideas came from, I'm trying to say the "camps" are stereotyping which shouldn't be brought up in a technical conversation. Traits and TypeClasses share the same fundamental idea and purpose, and Haskell TypeClasses is its own variant of that idea, which is slightly different to Standard ML TypeClasses as well, and to how other FP languages do ad-hoc polymorphism, and in OO languages there are many variant on that idea as well.