How is Functional Programming different from OOP? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 11

How is Functional Programming different from OOP?

Looking for a short straightforward comparison/evaluation

23rd Jul 2019, 1:47 PM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar
5 Answers
23rd Jul 2019, 2:26 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 6
Alan Kay, who had coined the phrase 'Object-oriented', states that OOP and FP are actually not that far from each other, and instead of being rivals they rather complement each other. Both approaches have shortcomings that are not properly solved in mainstream languages, even though the solution has been around for 60 years. This is quite a heavy read but I found very interesting https://www.quora.com/Why-is-functional-programming-seen-as-the-opposite-of-OOP-rather-than-an-addition-to-it/answer/Alan-Kay-11?share=a52bda70&srid=s4tO
23rd Jul 2019, 6:35 PM
Tibor Santa
Tibor Santa - avatar
+ 4
In FP, everything is done via functions and there is no storing of a global state.
24th Jul 2019, 3:50 AM
Sonic
Sonic - avatar
+ 3
I've just started to experiment with functional first languages, so my understanding is limited so take what i say with a grain of salt. In OOP you organize logically related data into objects (classes). Objects store their own states in variables. Objects also have attached behavior, which are functions (methods) that specify how an object can modify its state. In functional languages you don't have variables, what you have instead are values. You have simple values like for example the simple numerical value of 5 and you have function values (x+1) which in essence are procedures explaining what output to produce for a given input (lambda calculus). So in a functional language you build your program from values and value manipulations while in oop you build your app from objects which store behavior and mutatable state.
24th Jul 2019, 9:08 AM
Ádám Nagy
Ádám Nagy - avatar
+ 1
in OOP every object stores it's values and everthing it needs or is related to it is inside of it. i guess in functional programming everything is inside a giant melting pot 😂
23rd Jul 2019, 1:50 PM
Anton Böhler
Anton Böhler - avatar