13 ms·
Functional languages support this view, with powerful features like Haskell's typeclasses and Clojure's protocols and multimethods. It really boils down to the
by kyllo 11y ago
Functional languages support this view, with powerful features like Haskell's typeclasses and Clojure's protocols and multimethods.
It really boils down to the expression problem. If you imagine a grid of implementations where rows are datatypes and columns are functions, you want to be able to extend the grid with new rows and columns easily (and if you're working in a static language, without recompiling the code representing the other grid cells). OOP languages make it easy to add new rows (types) but more difficult to add new columns (functions) that work on existing types. Functional languages are the other way around. But Haskell's typeclasses and Clojure's protocols (basically forms of function implementation inheritance) make it easy to add rows and columns to your expression grid.
https://www.ibm.com/developerworks/library/j-clojure-protocols/ https://www.ibm.com/developerworks/library/j-clojure-protoco...
http://paulkoerbitz.de/posts/Solving-the-Expression-Problem-in-Haskell-and-Java.html http://paulkoerbitz.de/posts/Solving-the-Expression-Problem-...