What are the Programming Paradigms?

Ceyda Ulubas Tanfener
5 min readMar 24, 2023

--

A programming paradigm is a method or way in which we write code to solve different types of problems and there are many paradigms that we can use to write code also every programming language has a paradigm or number of paradigms that are best suited for it.

What types of paradigm categories do we have?

The top-level categories are imperative and declarative.

What is the meaning of imperative and declarative?

Imperative is one of the oldest paradigm categories and is the closest to low-level machine architecture, it writes by defining an explicit set of commands in sequence and runs it step by step. The main focus of paradigms in this category is: How to achieve a certain goal. The imperative paradigm can break problems into much smaller forms.

Declarative category focuses on logic and concepts rather than sequential flow in other words it specifies the result that you want to get and not how to get it and it is concerned with what needs to be done rather than how it should be done.

For example, if you are developing a drawing program, you have to describe all the process details with an imperative approach, but in a declarative paradigm, it is enough to say only draw a square.

Javascript is a multi-paradigm language but what does it actually mean?

It basically means it’s pretty flexible and supports different types of programming styles such as procedural, object-oriented, or functional.

IMPERATIVE PARADIGM

  1. Procedural Programming Paradigm

Its idea behind it is the same as its parent that I wrote about below. This is like a recipe for the computer to follow the code that can be reused in different parts of the program if you separate some parts nicely and put them into functions, another benefit is that it is simple to read and understand although there are some difficulties when dealing with complex problems.

Procedural Programming Languages: (Basic, Pascal, C, C++, Java)

Procedural programming may look like this

2. Object Oriented Programming

One of the most popular programming paradigms is object-oriented programming (OOP). It has a different path as the code is divided into classes that have different properties and can perform different actions. Objects created from these classes are intended to communicate with each other and inherit methods and properties from each other.

What are the advantages of OOP?

  • Creating objects collect in one class and can be used in all projects.
  • Thanks to the creation of classes once, they can be run with short codes instead of rewriting long codes.
  • The development process is shortened by avoiding rewriting long code.
  • Since the objects are independent of each other, it provides an advantage in terms of information confidentiality.
  • Object creation is collected in a class and allows usability in all projects.
  • Thanks to classes, instead of making changes in all projects, changes are made in a single class and it works in all projects. This greatly reduces the waste of time.

OOP Languages: ( Simula: first OOP language, C++, Objective-C, Java, Python, Ruby )

OOP example in javascript

3. Parallel Processing Approach

Parallel programming is commonly used in applications that require high computing power, such as scientific simulations, data analysis, and machine learning. By dividing a large task into smaller parts and executing them in parallel, programs can take advantage of the processing power of modern CPUs and GPUs, which can significantly improve performance and reduce processing time.

DECLARATIVE PARADIGM

  1. Functional Programming

Functional Programming has its roots in mathematics and is somewhat a language-independent paradigm. This means you can implement it in many programming languages. You can write functions that do basically any type of task without using a global state or mutating any global values that’s where immutability comes into play. It also tries to avoid things like loops and instead relies on recursion this paradigm generally reduces complexity but in some cases. This approach allows developers to write code that is more concise, modular, and easier to reason about, leading to fewer bugs and more maintainable code. However, functional programming can sometimes be less performant than imperative programming due to the need to create and pass around new data structures, which can be costly in terms of memory and CPU usage.

2. Logic Programming Paradigm

The logical programming paradigm isn’t widespread in web or mobile development. Because it is based on the use of mathematical logic to solve problems. In logic programming, the focus is on specifying the problem to be solved, rather than the step-by-step instructions for solving it. Programs are written in terms of logical statements or rules that describe relationships between objects and how they can be manipulated.

The best examples would be prolog and datalog.

The most well-known example of a logic programming language is Prolog.

Logic Programming Paradigm example

3. Database Processing Approach

The Database Processing Approach is a programming paradigm used to develop applications that work with database management systems (DBMS). This approach involves using a specialized programming language for database management to design, create, query, and manage databases.

This approach is used to perform operations on databases that store data. Database operations include querying, adding, deleting, and updating data. The Database Programming Approach ensures that data is stored correctly, easily accessible, and updatable. This approach is particularly useful for managing large and complex databases. Many users can access databases at the same time and these users can make changes to the database.

Resources :

--

--

No responses yet