Functional Programming vs Object-oriented programming - Please comment as well!
I don't have a vote. I grew up on procedural programming, and OOP came hard to me. Functional is pretty easy, in my mind, and OOP is now natural to me. I think whatever is best for the project.
Both can be easy or hard to work with depending on the project. To choose the right one for your project , I'd like to quote a stackowerflow answer:
None or Both it depends on your mindset and what you've learned.
I think both of them complement each others but I'm not a purist. I am a pragmatist in the end.
So concurrency I want to solve functional. Communication between components I want to solve in a OOP manor.
One important thing is that you have to consider that functional programming is supported as soon as you have
Which most modern OOP languages support. So you can code functional in OOP but you cannot code OOP in functional languages.
Both try to solve the "global mutable state" issue
So I personally don't think any of the paradigms is easier to learn, and tbh I think basic functional programming is more approachable because "add(x, y)" is easier to understand than "class calc { public add(x, y) }" since now you have to understand what is a class, what are access rights and so on.
but it boils down to taste in the end I guess ....
OOP is better orienation because you only use what you need. OOP is like bunch of wardrobes with drawers and when you need something just go and pickup what you need. From server side, in OOP , server pickup only class names and keep them in own memory. When you open that class, server only then start to indexing and looking objects (functions, variables, etc.) inside that class. If you work ony with functions (not OOP), server indexing all functions what you have and you waste more memory on "junks". Also OOP is code-less aproach if you learn how to handle with objects.
Advantage of OOP is also modular approach. You can always extends your functions, easy find error or use any object anywhere. Also you can give permission for each function (object) inside class and decide what is public, protected or private.
Best approach to learn OOP is that if you know made functions, just simply classify that functions inside one or few class, call class and it's functions where you need. Is simple approach and you will start to learn orientations. Next approach is to give permissions to that functions. Next approch is to use functions inside functions, collect one algorythm what you have inside many functions, place in one private function and include like object where you need etc. Learn slowly and wise.
Ivijan (Stefan) Stipic
Professional Senior Web Developer
Benjamin Herzog
I also think that this is really hard to answer. OOP is easier to understand because it often maps real world problems in computer code. FP doesn't wrap the objects but the operations on that objects.
FP has no side effects which makes it easier to work with but is harder to read in my opinion.
I work with OOP but use some paradigms and patterns from FP in there (map, flatMap, etc).