|
I was reminded of Anton van Straaten's "koan" on closures vs. objects with venerable master Qc Na [1] ... but I digress. This post is actually a troll post designed to re-ignite fiery discussions about which is the superior PoV - functional or oop - and I'm going to bite. The only point I'm willing to give is the somewhat sane zen-like advise of "don't fall in love with your models". Regarding OOP, I recall Alan Kay saying something to the effect of "OOP is not about objects. It's all about messages." which nicely points to the dualism between the two points of view. > There exists things that are not objects. Functions are not objects.
Well, objects are any "thing" that you can talk about, toss about in your head. Functions are certainly such "things" and count as "objects" in that sense. If we accept that "monotonic" is an adjective, i.e. an attribute of a noun, then the function described as "monotonic function" is an "object". > There exists things that are not pure. Side-effects are very real.
Um, how so? One notion that characterizes side-effects is irreversibility. You cannot unlaunch a rocket, for instance and so it counts as a "side effect" of the code "launch rocket". Despite that, when we look at the basic equations of quantum mechanics, they are all pure unitary! I mean, not only are they perfectly reversible, quantum "information" cannot be destroyed or even copied. So with fundamental physics we have the opposite question - how the hell do we get "side effects" out of this much purity at the core? > Also purely functional languages cause a huge cognitive cost.
I call pure BS on this section. "Huge cognitive cost"? For whom? Wouldn't "structured programming" have placed huge cognitive costs to former "goto programmers"? It is more honest to just say "I don't understand monads, so I won't use them." > If you look deep into them, monads make programs complicated and hard to write
Again, "complicated" for whom and "hard" for whom? Is there some objective sense in which such declarations can be made? I, for one, have benefited greatly from learning about monads, reading monadic code and recognizing the pattern in existing code. > You can write pure functions in any language, but the important thing is, you should be allowed to use side-effects too.
Why? Who's to say you "should" this or "should not" that? > Everything starts to do harm when they are pursued to the extreme.
I'd say the exact opposite actually. Both OOP as well as the functional perspective here illuminate the programming world only when taken to the extreme. Until then, folks just keep arguing about what is functional and what is oop and what isn't. Haskell and Smalltalk/Self have done this favour for us by adopting these extreme dual perspectives.[1] http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/m... |
(edit) [3] is a quote from a communication with Kay in 2003 -
"OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them."
[2] https://www.youtube.com/watch?v=oKg1hTOQXoY (around 38minutes)
[3] http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay...