4

I am reading a book about Lambdas expression in Java and I came across this sentence

The difference is that object-oriented programming is mostly about abstracting over
data, while functional programming is mostly about abstracting over behavior.

Can anyone be kind and elucidate the difference that is mentioned in above sentence?

Source : http://shop.oreilly.com/product/0636920030713.do

Kick Buttowski
  • 6,709
  • 13
  • 37
  • 58

2 Answers2

3

The irony is that people can come up with infinite analogies when trying to compare FP to other paradigms.

In this particular case once you figure out what does "abstracting over something" means, you could solve the riddle.

Abstracting over something would mean you hide the details of that something and provide abstractions to access that something so that to the outside world the details of that something are not visible.

Applying the above theory we would get that:

In OOP you would hide the details of data and provide abstractions (interfaces, classes etc) to access the data.

In FP you would hide the details of behavior and provide abstractions (modules i.e a set of functions) to access the behavior.

Ankur
  • 33,367
  • 2
  • 46
  • 72
  • is this statement true: "In OOP you cannot do abstractions over behaviour"? I think otherwise, it is not that strict. If the behaviour is how to do things, we do often hide implementation details (if that implementation details represent a behaviour). – Talha Dec 29 '21 at 08:39
1

I would have written it like "The difference is that object-oriented programming is mostly about relation and communication between real time objects,while functional programming is mostly oriented to the desired result."

When you are working in OOP languages, the given domain is usually very importent to you. On the other hand, with functional languages you do not care about the domain but only about the deterministic result which should be achieved.

Mirek Surma
  • 148
  • 1
  • 10
  • can you provide your source please? – Kick Buttowski Jun 23 '14 at 03:34
  • 1
    There is no source. That is only interpretation of how I feel it. Maybe try read something about haskell which is very representative of FP and you get your own feeling of the difference between OOP and FP. – Mirek Surma Jun 23 '14 at 03:38
  • 1
    I think it is almost must to understand some FP language to do the lambdas well in java. I started to learn haskell because of the java lambdas and now it seems to me absolutely natural in java because I see it from the functional point of view. – Mirek Surma Jun 23 '14 at 03:43
  • 2
    Might it be valid to say that: with OOP the interactions between data is more unknown and complex but the data itself is clear and strict, whereas with FP the data is more unknown and complex and the interactions are clear and strict? – Perry Monschau Jun 23 '14 at 04:00
  • @PerryMonschau i like your comment. It make sense to me – Kick Buttowski Jun 23 '14 at 04:05