Objection-Oriented Programming and Functional Programming are simply different approaches to the same problem. They are both a programming paradigm is well writing code compliant with a specific set of rules.
|Object-Oriented Programming||Functional Programming|
|Few functions and common data||Many functions and fixed data|
|Side effect||a few side effect|
Why functional programming is becoming popular is that because of the idea of a few side effects. it means that we can start running code in parallel on multiple processors and it won’t have an effect on our program but Object-Oriented Program has more side effects. Also, functional programming is more declarative it is about what we want to be doing versus object-oriented programming which is more how we want it to be done which is more imperative. So when should you use one over the other? Functional programming is quite good at processing large data for application if you are analyzing.
Functional programming works really well for high performance and processors because you can run it on multiple processors. If you have a few things that require a lot of operations a lot of little functions applied to it well then functional programming is usually a good idea. On the other hand, you have many things with not too many operations then Object-Oriented Programming might be a better solution, but you can use the ideas from both of these to write the code.