The Basics of Programming Paradigms

I was previously asked in a job interview about the different types of programming languages. Specifically, I was asked about the C programming language. I answered that it was a structured language, but the interviewer said otherwise, that it was not structured but imperative. To my knowledge, structured languages are part of imperative ones so basically it would be the same.

There are a lot of classifications, which you can take into account when grouping programming languages. You can classify them whether they are compiled or interpreted, are dynamic or static typed, are object-oriented or non-object-oriented, are assembly or high-level, and lastly if they are declarative or imperative.

Note that each programming language can include multiple programming paradigms from the below:

1. Imperative Programming Paradigm:

With imperative programming, we usually tell the program how to do the work with instructions like a recipe.

1.1 Non-structured Programming:

They are the earliest type with Turing-complete algorithms. The entire program is written step-by-step in linear fashion to form one complete functionality. This paradigm evolved later on into structured. Examples are Pure Assembly languages.

1.2 Structured Programming:

With structured programming, functions came into existence, and the whole algorithm is broken down into smaller blocks and functions. These functions can then be re-used. Examples are C, C++, and Java.

1.2.1 Procedural Programming:

Procedural languages are a subset of structured languages. They are all function-based code that is not object-oriented. By procedural programming, the structure is dominated by functions versus data and state. They contain block structures like for and if-else loops. Some may consist of different modules, which can be re-used and shipped. Examples are Basic, C, C++, Python, and PHP.

1.2.2 Object-oriented Programming:

All structured code that is object oriented as well. Here, classes and objects are represented. The structure is dominated by data and state. Examples are Java, C#, PHP, Ruby.

2. Declarative Programming Paradigm:

With declarative languages we tell the program what to do instead of how to do it. In other words we can compute without describing the control flow of the program. Examples are SQL and CSS.

2.1 Functional Programming:

It is a subset of declarative languages where functions, as the name of the paradigm indicates, is widely used. Functional languages are about data flow and handling state via parameter passing. Opposite to object-oriented languages, there are no side-effects regarding state and they use only expressions. Examples are Haskell, Lisp, Closure, and Elixir.

2.2 Logic Programming:

It is a subset of declarative languages where the program is constructed based on logical form and clauses. Example is Prolog.


Show Comments