Difference between Functional Programming and Object-oriented programming.
Hi, I am Thushal. I am an undergraduate at the University of Kelaniya Sri Lanka following a Bachelor in Information Communication Technology degree program. In this article, I am going to elaborate on the differences between Functional Programming and Object-oriented programming. First, let us see what is functional programming.
Functional programs perform similarly to ordinary math functions, such as the calculations behind a Celsius-to-Fahrenheit conversion. The same inputs consistently yield the same output when using functions. A “pure” function is deterministic and doesn’t have any side effects, meaning it always returns the same value when called and doesn’t change anything outside of its scope or parameters.
Object-oriented programming, on the other hand, can include state-dependent variables, which means that objects don’t always keep the same values. If you call a method that returns a salary, for example, you can get LKR 50,000 back. However, if you apply a 10% increase to that sum and then ask for the salary again, the result is LKR 55,000. Global variables and static variables may be included in object-oriented programming, resulting in unique replies to queries each time.
The below table includes a comparison between functional and object-oriented programming.
Now you might have a basic idea about what functional programming and object-oriented programming are and how both differ from each other. Thank you so much for reading and stay tuned for another article.