Object Oriented vs Functional Javascript | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Object Oriented vs Functional Javascript

Objected oriented programming is bulky, has side effects etc. Functional programming is clean, doesn’t have side effects etc But when should you use one and not the other? Are there circumstances where you’d use both?

27th Apr 2019, 10:05 PM
Logomonic Learning
Logomonic Learning - avatar
5 Answers
+ 3
Most modern languages are OO with a bit of functional thrown in, so you will usually be using both at the same time. OO: classes, objects, ... FP: lambdas, higher-order functions (.map, .reduce, ...), ... Functional code can have side effects I think, just the language that I keep on rambling about in this forum doesn't have them, and a few others. There is the so-called "expression problem" that discusses which types of problems functional can do well, and which code OOP can do well. But there are solutions to the problem in most languages. It is worth checking out though.
28th Apr 2019, 9:46 AM
Schindlabua
Schindlabua - avatar
+ 2
From my experience i see more functional languages in science and more object oriented langiages in the software industry. But you can both both ways. It completly depends on what you wanna create and what languages you know.
27th Apr 2019, 10:09 PM
Dragonxiv
Dragonxiv - avatar
0
Yes Dragonxiv , So they can be used interchangably on a project? but which circumstances would you use one over the other, any valid examples?
28th Apr 2019, 12:26 AM
Logomonic Learning
Logomonic Learning - avatar
0
If you wanna create your own game engine i would choose c++. C++ has the benefit of having nice access to both directX and opengl. Also there is a big community out there doing the same so you have many resources to learn from. So in this example i can pinpoint a single language which i would recommand.
28th Apr 2019, 6:38 AM
Dragonxiv
Dragonxiv - avatar
0
Dragonxiv recommend for what?, how does this relate to oop and fp?
28th Apr 2019, 9:58 AM
Logomonic Learning
Logomonic Learning - avatar