top | item 35766696

(no title)

curryhoward | 2 years ago

Most of the functional programmers I know have a deeper understanding of OOP than the OOP programmers I know. For example, most of the OOP programmers I know do not understand covariance and contravariance (whereas just about every functional programmer I know has mastered them), even though those concepts frequently come up in the context of OOP. People who study programming language theory tend to gravitate toward the functional paradigm, but it's not because they don't understand OOP.

discuss

order

jove_|2 years ago

If you aren't aware that contra and covariance are typically taught under the banner of the "liskov substitution principle" rather than with the name variance you don't know OOP better than OOP programmers. You just convinced yourself you did because you use different terminology. I think maybe the guy you're responding to is correct.

charcircuit|2 years ago

>most of the OOP programmers I know do not understand covariance and contravariance (whereas just about every functional programmer I know has mastered them)

I very much doubt this and I suspect it is more of a problem of how you framed it. I'm sure you would see more success if you framed it seeing if the following would compile.

    List list = new ArrayList<String>;
and for contravariance ,which is something that is not very common in practice

    Consumer printHashCode = o -> System.out.println(o.hashCode());
    Consumer<String> printStringHashCode = printHashCode;

gizmo686|2 years ago

Where is the variance in your example?