Covariance and contravariance are wonderful ways to notice key OO design problems. Unfortunately it is very hard to learn to think that way. Consider an OO language with classes and inheritance. Each class is a type. (There may be types that aren't classes, for example Java an interface also represents a type. The equivalent in a dynamic language with duck typing is "all objects that satisfy this contract".) An objec…
Is there really enough value in subtyping to keep it around? Sure, lots of things in the real world are naively "is-a" relationships, eg. interface Fruit { boolean isSoft(); } class Apple implements Fruit { boolean isSoft() { ... } } class Banana implements Fruit { boolean isSoft() { ... } } But this is both less explicit and less flexible than modelling it as a "has-a" relationship, eg. interface Fruit { boolean isS…
(0) Inheritance is a (rather undisciplined) form of code reuse - it's literally automation for copying and pasting part of an existing definition into the body of another. It doesn't presuppose a notion of type.
(1) Subtyping is a semantic relationship between two types: all terms of a subtype also inhabit its supertype(s).
There's nothing too wrong with inheritance as long as you're aware that it doesn't always lead to the creation of subtypes. This is, for example, the case in OCaml.
Sadly, Java, C# and C++ confuse matters by conflating classes with types (which is tolerable) and subclasses with subtypes (which is a logical absurdity and leads to painful workarounds, I mean, design patterns, as we all have learnt the hard way).