News for hackers. Stuff that matters.
Re:FP vs. OO, from the trenches by bad_user on Monday July 22, 2013 @02:38PM (#6085631)
OOP is not about hiding / dealing with mutable state, although it can be used that way, but that's a perverted idea of what OOP is.

OOP is about subtype polymorphism [1] by means of runtime single-dispatch [2] and modularity, as in abstract modules or components that help with decoupling, a notion supported explicitly by SML, or exemplified beautifully in the Cake-pattern used in Scala.

[1] https://en.wikipedia.org/wiki/Subtyping

[2] https://en.wikipedia.org/wiki/Single_dispatch

Re:FP vs. OO, from the trenches by cygx on Monday July 22, 2013 @02:55PM (#6085752)
For me, OO means stateful objects communicating by message passing, and same as asdasf, I consider it a way to structure imperative code. I don't consider this a perversion - it goes back to Kay.

Your definition is of course an equally valid one that might be more appropriate in certain contexts - it just doesn't fit my mental model of computation equally well.

Re:FP vs. OO, from the trenches by chipsy on Monday July 22, 2013 @03:30PM (#6085964)
I've developed the opinion, based in large oart on Kay's thinking, that the biggest wins of OO are better represented as a form of protocol design. The point of impedance comes in when you discover that not all protocols map cleanly to OO systems - some are synchronous and others asynchronous, some require more polymorphism than others, etc. Async message passing happens to be one of the more flexible mechanisms for protocol design, but it's only been relatively recently that industry languages have been considering it more carefully, and then it's framed as "concurrency" and not a general architectural consideration.

Likewise I see FP as a reactionary mechanism to write fewer and simpler protocols, because when the data is immutable the problem can usually be greatly simplified.

Re:FP vs. OO, from the trenches by munificent on Monday July 22, 2013 @03:33PM (#6085982)
> OOP is about subtype polymorphism [1] by means of runtime single-dispatch

I believe CLOS would beg to differ.

Re:FP vs. OO, from the trenches by cgore on Monday July 22, 2013 @04:54PM (#6086405)
Other than that I would agree with him though. Subtype polymorphism + runtime (single or multiple) dispatch.

Multiple dispatch is one of the things I really miss about Common Lisp. I do like OOP, but often the most intuitive way to think about something is multiple dispatch, and trying to shove it into a single dispatch model can produce some really ugly code. I'm pretty sure that is the main reason there are so many anti-OOP zealots in the world.

Also, I didn't realize Dylan had multiple dispatch. I should take a look at it sometime.

Re:FP vs. OO, from the trenches by andrewflnr on Monday July 22, 2013 @08:57PM (#6087523)
Clojure does, too.
Re:FP vs. OO, from the trenches by seanmcdirmid on Monday July 22, 2013 @04:35PM (#6086302)
OOP is most definitely defined by encapsulation of state into objects that have identities. There are many points to deal with messaging, on the other hand, as well as polymorphism, which are all compatible with what OO is from a design perspective. Otherwise, the anthropomorphic properties of the object are no longer sustainable, and it's noun-ness disappears.

The cake pattern has as much to do with encapsulation as it does crosscut composition.