A programming paradigm is a philosophy and an approach to writing code. Also, it is a way to classify programming languages according to their style of programming and features they provide. There are several features that determine a programming paradigm such as modularity, objects, interrupts or events, control flow etc.
Some languages are designed to support one paradigm, for example Haskell supports functional programming, while other programming languages support multiple paradigms C++, Java, C#, Scala, PHP, Python, etc. For example, programs written in PHP can be purely object-oriented, or can contain elements of other paradigms. Software developers decide how to use those paradigm elements.
There are various programming paradigms, the most popular programming paradigms we will cover in this article:
Some Common Programming Paradigms
- Imperative programming
Let’s start with the Imperative programming; the oldest paradigm, but it is still in practice. It is the widely practiced paradigm in the day-to-day programming. It mainly focuses on steps to be done and works on the logic of “First do this then do that”. Control flow in imperative programming is explicit: commands show how the computation takes place, step by step. Each step affects the global state of the computation. Programs written in the imperative style are often similar to recipes, for example first clean the carrot, then cut it, then put it in a oven, etc.
Examples of imperative programming languages are – C, C++, Java, Kotlin, etc.
- Declarative programming
As for the declarative programming, it focuses on the logic of computation neglecting the control flow. It specifies what the result should be, without specifying how to obtain the result. Declarative programming generally does not contain if-else, loops and other control flow statements.
Popular declarative programming languages are: SQL, XQuery
- Structured programming
Structured programming is a kind of imperative programming, but it focuses on modular programming. Structured programming was introduced as an improvement over the imperative programming approach to get more control over the program.
Examples of structured programming languages are C++, Pascal, Ada etc.
- Object oriented programming
Object Oriented Programming paradigm is widely practiced programming paradigm. It is based on the concept of objects. Objects are real world entity. Every object has two important property attribute (data) and behavior (function). It is based on the sending of messages to objects. Objects respond to messages by performing operations, generally called methods. Messages can have arguments. Object-oriented programming deals with state by designating certain functions that operate specifically on that state.
Popular object oriented programming languages are – Simula-67, Java, C++, C# etc.
- Functional programming
Functional programming paradigm is completely different programming approach from all paradigms mentioned above. Functional programming uses a combination of functions calls to drive the flow of the program. The result of a function becomes the input to another function.
Popular functional programming languages are – Python, Lisp, Clojure, Haskell, Scala, etc.
It is up to you to choose which paradigm to choose, depends on your objectives and strategies.
Guest article written by: Ekaterina Novoseltseva is a CMO at Apiumhub – software development hub, which is specialized software development and software architecture.