Live data from Hacker News

Where FP meets OO

christopherhunt-software.blogspot.com

61–64 of 64 posts

Re: Where FP meets OO

#62
post #4

"Scala is the only language that I know of that marries the world of FP and OO" You can do that in C#/F# too. There's nothing special about Scala from this point of view.

Nope. Scala allows for and promotes for functional programming with higher order functions all over the place, its more powerful type system, immutability, practices, standard library, and much more. Having lambdas makes you about as functional as C++ these days. Functional/non-functional is a fuzzy distinction but C# is definitely not a functional language.

There be no true Scottsmen here. Scala is also great as an imperative language and an OO language. In fact, I would say Scala has one of the most powerful natively supported object systems out there (mostly because the rest of the statically typed language world can't be bothered to support mixins, grr...).

If it wasn't for nerfed imperative collection classes (to encourage functional solutions) in the standard library, you could totally just ignore the fact that Scala was a functional language at all; it is not in your face about it like Haskell.

It would probably be more correct to say that "Scala is the only language that does both FP and OOP very well." On marrying the paradigms....why not just use both as needed anyways? That is completely doable in C# as well, just not as well as in Scala.

Re: Where FP meets OO

#63

OCaml also has both, and its object system is probably more powerful.

How come?

Besides the object system, OCaml has a powerful module system, with first-class modules and functors (which is already basically very equivalent to what you'd expect from objects).

Besides that, objects have structural typing, and you can even create objects without classes (somewhat similarish to anonymous classes, except instead of interfaces you have the structural typing to give you something like statically typed duck typing).

OCaml also has multiple inheritance and friend classes.

Re: Where FP meets OO

#64
post #41

Earlier quoted context omitted.

To me, OOP is, first and foremost, about messages. Everything else is negotiable.

Messages, across boundaries is more FP than OO though... it actually adds complexity to do this in an OO paradigm.

What do you mean with complexity?
Post reply on HN