A List of Popular Programming Paradigms

programming paradigms

There is a plethora of programming languages out there, each one meant for a different purpose and application. Features, behavior and design of a programming language is decided by the paradigm based on which it is built. Programming paradigms are a way of grouping the different programming languages based on their features, behavior, design and application. In this article, I shall introduce you to some of the most popular programming paradigms, ideologies behind them and how they solve the problems they are designed to solve.

What is a programming paradigm?

In simple terms, a programming paradigm is an approach taken to solve a problem. It is the basis on which programs and their elements are created. A single programming language may support more than one programming paradigm. For instance, Haskell is a programming language that supports only the functional programming paradigm while languages like Ruby and Python, though they’re built to favor the object oriented paradigm can support functional paradigm as well.

1. Object Oriented Paradigm

In the Object Oriented Paradigm, everything in a program is treated as an object. Methods, closures, data structures are all objects in an object oriented programming language. Object oriented paradigm is the most popular programming paradigm because of its unique advantages like the modularity of code and ability to directly associate real-world business problems in terms of code.

Objects are instances of classes. Objects have attributes and methods. Attributes are data associated with the object while methods are actions/functions that the object can perform.

Advantages of The Object Oriented Programming Paradigm

  • Modularity of code making it more reusable.
  • Easier to translate business logic to code.
  • Code Maintenance is easier as the code is more readable.
  • Improved Scalability.
  • Enhanced productivity.

Shortcomings of The Object Oriented Programming Paradigm

  • Applications tend to be larger in size.
  • Reduced performance due to large application size.
  • Development requires specialized knowledge.
  • If not written well, code can get messy pretty quickly.

Languages That Support The Object Oriented Paradigm

  • Python
  • Ruby
  • Java
  • C++
  • Smalltalk

2. Functional Paradigm

The functional programming paradigm has been in the limelight for a while now since JavaScript, a functional programming language has gained more popularity recently. It is a style of programming with pure mathematical functions. It makes use of functions to transform data from one state to another. In the functional programming paradigm, the functions do not modify any values outside the scope of that function and the functions themselves are not affected by any values outside their scope.

Due to the lack of a shared state, the functions require variables to be passed into them explicitly as parameters. Return value of functions will remain the same as long as the parameters are not altered. For example, the function add(1, 2) will always return 3.

Advantages of The Functional Programming Paradigm

  • The code is almost always precise and succinct.
  • Predictable Output makes testing easier.
  • Succinct code implies faster execution of programs.
  • Implementation of Concurrency and parallelism is easier.

Shortcomings of The Functional Programming Paradigm

  • Immutable variables imply the need for duplication of data which can become memory intensive especially when creating recursive functions.
  • Difficulty in creating code that is scalable.
  • Integrating functions to create a program is harder than you think it is.

Languages That Support The Functional Programming Paradigm

  • Haskell
  • OCaml
  • Scala
  • Clojure
  • Racket

3. Imperative Paradigm

In the Imperative Programming Paradigm, results are achieved using sequential statements that modify the state of the program. This paradigm requires the programmer to explicitly code every single statement necessary to achieve the desired result which implies that the option of using pre-coded modules is unavailable in this paradigm. This paradigm was introduced when only primitive languages like assembly and FORTRAN were available.

The output of imperative programs are usually executable files which execute really quickly since the CPU Instructions themselves are imperative in nature.

Advantages of The Imperative Programming Paradigm

  • Statements easily map to the CPU ISA Instructions which is the closest you can get to the underlying hardware.
  • Executes really fast especially in case of primitive languages like Assembly.
  • Step by step specification of the program flow offers greater control over the outcome of the program.

Shortcomings of The Imperative Programming Paradigm

  • No Modularity.
  • Maintenance is a nightmare.
  • Level of abstractions that can be generated is limited.
  • Order of execution of really important.

Languages That Support The Imperative Programming Paradigm

  • Ada

4. Declarative Paradigm

The declarative programming paradigm is an approach where the output of the program is defined by the programmer without defining how the output is to be achieved. The control flow of a declarative program is implicit. In declarative programming, the language implementation is responsible for generating the output prescribed by the programmer. Declarative programs use expressions instead of statements to achieve the desired output. Application of the declarative paradigm has a limited scope. It is mainly used to develop Domain Specific Languages (DSLs) and not programming languages.

Advantages of The Declarative Programming Paradigm

  • Conceals lower level operations to help focus on the logic of a program.
  • The code is almost always very compact as only the output is defined.
  • Better code readability.
  • Code Reusability

Shortcomings of The Declarative Programming Paradigm

  • The developer has no control over how output is achieved.
  • Does not have all powers of a programming language.

Languages That Support The Declarative Programming Paradigm

  • SQL
  • Regular Expressions
  • HTML

These are the most popular programming paradigms in the world of software development. Though the programming paradigms exist, the pure implementation of any one paradigm in a programming language is very difficult to find. Most languages are multiparadigmatic in nature.

I have provided a concise overview of the paradigms. If you’d like to see detailed explanations of any of the above paradigms, leave a request in the comments below and I shall feature it in a future article.

Sreedev Kodichath

Sreedev Kodichath, a passionate software engineer, an avid blogger & an eloquent orator is the author of DevTechnica.

Leave a Reply

Your email address will not be published. Required fields are marked *