DEV Community

Cover image for object oriented, procedural and functional programming
betpido
betpido

Posted on

object oriented, procedural and functional programming

Object-oriented programming (OOP) is a programming paradigm based on the concept of objects, which can contain data and code.

In OOP, computer programs are designed by making them out of objects that interact with one another.

An object is an instance(example, copy) of a class, which is a blueprint for creating objects.

A class defines the properties and methods that an object will have. Properties(characteristics) are the data that an object contains, while methods are the functions(actions) that an object can perform.

Many of the most widely used programming languages (such as C++, Java, Python, etc.) support object-oriented programming.

difference between OOP and procedural programming:

In procedural programming, a program is divided into small parts called functions. These functions consist of a series of computational steps to be carried out.

During a program’s execution, any given procedure might be called at any point, including by other procedures or itself. Languages used in procedural programming include FORTRAN, ALGOL, COBOL, BASIC, Pascal and C.

In object-oriented programming (OOP), computer programs are designed using the concept of objects that interact with the real world. Objects contain data in the form of attributes and code in the form of methods.

A class defines the properties and methods that an object will have. Properties are the data that an object contains, while methods are the functions that an object can perform.

In procedural programming, the program is divided into small parts called functions. In OOP, the program is divided into small parts called objects.

Another difference is that OOP provides data hiding so it is more secure than procedural programming which does not have any proper way of hiding data.

In OOP languages, access specifiers like private, public and protected are used to control access to data and methods.

difference between OOP and functional programming:

In functional programming, programs are constructed by applying and composing functions.

Functions are treated as first-class citizens and can be passed as arguments to other functions or returned as values from them.

Functional programming languages include Haskell, Lisp, Scheme, ML and F#.

Functional programming emphasizes on immutability and pure functions. Pure functions do not have side effects and always return the same output for a given input.

This makes functional programs easier to reason about and test. In contrast, OOP emphasizes on encapsulation and inheritance. Encapsulation hides implementation details from users of a class or object.

Inheritance allows classes to inherit properties and methods from other classes.

functional programming languages:
Haskell, Lisp, Erlang

Top comments (0)