Programming Paradigms

java dev.to

what is programming paradigm

A programming paradigm is a method or style of solving problems using a programming language.

It provides a structured approach and set of principles that guide how programs are designed and implemented.

Different programming paradigms use different techniques and strategies.

A programming language may support one or more paradigms, allowing developers to choose the best approach based on project requirements.

Programming paradigms are two types :

  1. Imperative Programming Paradigm
  2. Declarative programming paradigm

Imperative Programming Paradigm

The imperative paradigm is centered on describing how a program operates. Code consists of step-by-step sequences of commands.

These contains three types, They are :

=> Procedural Programming: Organizes code into reusable blocks called routines, subroutines, or functions.

EXAMPLES : C, Coldfusion, pascal.

=> Object-Oriented Programming (OOP): Treats "objects" (which bundle both data and the behaviors that operate on that data) as the core building block. It focuses on concepts like inheritance, encapsulation, and polymorphism.

EXAMPLES : Java, c++, Python, Ruby.

=> Parallel processing approach: Parallel processing is the processing of program instructions by dividing them among multiple processors.

This is the oldest one and seems to be conquer.

Declarative Programming paradigm

The declarative paradigm focuses on what the final result should be, without explicitly detailing the step-by-step commands to get there.

These contains three types, They are :

=> Functional Programming: Treats computation as the evaluation of mathematical functions and avoids changing state or mutable data.

Programs emphasize pure functions that always return the same output for the same input.

Popular Languages: javascript, Haskell, Elixir, Lisp.

=> Logic Programming: Based on formal logic. You provide a set of facts and rules, and the system uses logical inferences to answer queries or solve problems.

Popular Languages: Prolog.

=> Data-driven / Query Languages: Allows developers to define the format of the data they need, letting the underlying engine handle retrieval.

Popular Languages: SQL.

Hybrid and Multi-Paradigm Approaches

Most modern languages are multi-paradigm. Languages like JavaScript, TypeScript, Python, and Rust allow developers to mix and match.

Source: dev.to

arrow_back Back to Tutorials