Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

general
oop

What is the difference between functional programming and OOP?

Yusra Masood

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

Functional programming uses functions and their evaluations to create programs. Contrarily, in Object-Oriented programming (OOP), objects and methods are used to represent everything.

Below are a few main differences between the two:

Programming model

Functional programming

The declarative programming model is followed, which means the control flow is not described with the logic of computations. The code does not specify the flow of the steps to be completed.

Object-oriented programming

The imperative programming model is followed, which means a control flow is defined. The code itself specifies how the problem is to be solved.

Data

Functional programming

The nature of data is immutable, which means that once it is defined, the state of the data can’t be changed.

Object-oriented programming

The nature of data is mutable, which means that the state of data can be changed after definition.

Iteration

Functional programming

Recursion is used for iteration. To iterate through anything n number of times, we use a higher-order function to call the main function n number of times.

Object-oriented programming

Control flow constructs such as while or for loops are used for iteration. A state variable is updated based on its value and specified rule for iteration.

RELATED TAGS

general
oop

CONTRIBUTOR

Yusra Masood
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring