Difference between Functional Programming and Object-Oriented Programming….

Gamindu Lalanaka
2 min readApr 13, 2022

--

Functional Programming

Functional programming is a declarative programming paradigm that writes in pure functions, meaning that these functions do not modify variables but instead generate new ones as an output. In other words, the output of a pure function only depends on the input parameters; thus, there is no external impact, which avoids side effects. Moreover, writing pure functions also helps developers avert mutable data and shared state.

Therefore, functional programming has many benefits and is used in a lot of programming languages and frameworks. It is a popular programming paradigm due to its ability to create maintainable and clean software by using functions, which are vital to code organization.

Object-Oriented Programming

Object-oriented programming is a programming paradigm that organizes data and the software structure based on the concept of classes and objects.

Classes are a set of instructions (or blueprints) that establish a data structure for a specific object, determining what the object will contain (the types of variables that can exist in an object) and how it will behave (the methods or member functions that define how to operate on the variables). Thus, objects are instances of classes since classes work as “templates” to create objects. Plus, objects can contain data in the form of fields (also known as attributes) and code in the form of procedures (also named methods).

--

--