I've been looking at Scala, OCaml, and F# recently and I've really been struck by their different approaches toward mixing OO and FP. I can't say that I like any particular approach, really. OO and FP do seem to be odd bedfellows in a language and I think that I see why now. They use syntax in rather different ways. If you aim for one unified syntax in hybrid FP/OO languages the things that you do to tune the syntax toward one end seem to detune from the other.
Let's take a look at how we structure function calls/applications across several languages:
Smalltalk: b a: c
Lisp: (a b c)
Haskell: a b c
The C syntax is a straight procedural. We have a function a and we need to pass b and c along. The Smalltalk snippet is in the object-oriented style. We privilege b and say that it owns the a method. We get polymorphic substitutability in the bargain. Lisp doesn't privilege any particular argument, so it is sort of like procedural, although people do write OO code in that style in Scheme and CLOS. The Haskell example, however, is very interesting syntactically, because it is tuned to make this natural:
let x = a b in x c
In this example, we've bound x to the partial application of a to b and then used it to form an expression x c which is semantically the same as a b c.
Partial function application is powerful. People working in Haskell and the other ML-derived languages use it routinely to compose operations. It's a shame, though that its syntactic style is so different from the OO style. Here's an example that drives it home. Imagine that we want to get the second element of a list in a couple of hypothetical languages. Here's a Haskell-ish way to do it:
head (tail [1,2,3])
and here's the OO-ish way:
See the difference? FP is more of a prefix style, while OO is postfix. One could say that this is arbitrary, that you could have an OO language which uses the prefix style, but I'd argue that there is something deeper here.
Let's imagine what our code would be like if we attempted to do partial function application with OO syntax.
let remainder = [1,2,3].tail in remainder.head
The partial function application doesn't really buy us much here. Partial application is powerful when it composes functions. Often the data that we are working with is the least interesting thing to compose, yet it comes first in OO expressions and the natural style of partial function application in language design is to keep the first N terms and leave off some trailing ones.
It does seem that functional programming gets some advantages from its prefix syntax. Scala, F#, and OCaml do show that you can mix the styles, but you can't really get a unified one without picking the prefix form or the postfix form. The ML derived languages have definitely found a syntactic sweet spot and it does seem like it's a poor mix with object orientation.