3 ms·
They are different in important aspect - in OOP, conformance to an interface is defined where the class (new type) is defined, while conformance to a type class
by js8 4y ago
They are different in important aspect - in OOP, conformance to an interface is defined where the class (new type) is defined, while conformance to a type class can be specified independently of type or type class definition.
This is really important for interoperability. With type classes, I can say that type (class in OOP) from library A conforms to a type class (interface in OOP) in library B (without A knowing anything about B), which is impossible to do with interfaces.
- Dylan16807 4y ago> I can say that type (class in OOP) from library A conforms to a type class (interface in OOP) in library B Does that involve adding code to make it conform? Either way, there are languages based on classes and interfaces where you can do that.
- js8 4y agoYes, the point is, the code to make it conform is independent on both A and B. So no need to modify either library. And sure, we can discuss what OOP is, but I am using the most widely used definition of classes and interfaces, as understood by Java and .NET.