📜 ⬆️ ⬇️

“Forgotten” programming paradigms



It turned out that those paradigms that used to break through into the light through the hordes of adherents of traditional methods were gradually forgotten. These paradigms arose at the dawn of programming and why they arose, what advantages they gave and why they are used so far it is useful for any developer to know.

Okay. The introduction is a lot of fun, but you don’t read it anyway, so whoever is interested is welcome under the cut!

Imperative programming



Historically, the overwhelming majority of the computing technology that we program has state and is programmed with instructions, so the first programming languages ​​were mostly purely imperative, i.e. did not support any paradigm except imperative.
')
These were machine codes, assembly languages, and early high-level languages, like Fortran.

Key points:


In this paradigm, calculations are described in the form of instructions that change the state of a program step by step.

In low-level languages ​​(such as assembly language), the state may be memory, registers, and flags, and instructions are those commands that the target processor supports.

In higher-level (such as C) states, this is only memory, instructions can be more difficult and cause memory allocation and release in the course of their work.

In very high-level (such as Python, if it is imperative to program), the state is limited only to variables, and commands can be complex operations that would take hundreds of lines on an assembler.

Basic concepts:


- Instruction
- Condition

Generated concepts:


- assignment
- Transition
- Memory
- Pointer

Languages ​​supporting this paradigm:


As the main:

- Assembly languages
- Fortran
- Algol
- Cobol
- pascal
- C
- C ++
- ada

As auxiliary:

- Python
- Ruby
- java
- C #
- php
- Haskell (via monads)

It is worth noting that most modern languages ​​support imperative programming to one degree or another. Even in pure functional Haskell language, you can write imperatively.

Structured programming



Structural programming is a programming paradigm (also a common definition is a development methodology), which was the first big step in programming development.

The founders of structured programming were such famous people as E. Dijkstra and N. Wirth.

The pioneering languages ​​in this paradigm were Fortran, Algol and B, and later their successors were Pascal and C.

Key points:


This paradigm introduces new concepts that combine commonly used patterns of writing imperative code.

In structured programming, we still operate with state and instructions, however, we introduce the concept of a compound instruction (block), branch and loop instructions.

Thanks to these simple changes, it is possible to abandon the goto operator in most cases, which simplifies the code.

Sometimes goto does make the code more readable, thanks to which it is still widely used, despite all the statements of its opponents.

Basic concepts:


- block
- Cycle
- Branching

Languages ​​supporting this paradigm:


As the main:

- C
- pascal
- Basic

As auxiliary:

- C #
- java
- Python
- Ruby
- javascript

Partially supported:
- Some macro assemblers (via macros)

Again, most modern languages ​​support the structural paradigm.

Procedural programming



Again, the increasing complexity of software made programmers look for other ways to describe calculations.

Actually, additional concepts were introduced once again, which made it possible to take a fresh look at programming.

This concept this time was the procedure.

As a result, a new methodology for writing programs has emerged, which is welcomed to this day - the original problem is broken down into smaller ones (using procedures) and this happens until the solution of all specific procedures is trivial.

Key points:


The procedure is an independent piece of code that can be executed as one instruction.

In modern programming, a procedure can have several exit points (return in C-like languages), several entry points (using yield in Python or static local variables in C ++), have arguments, return a value as the result of its execution, be overloaded by quantity or type of parameters and much more.

Basic concepts:


- Procedure

Generated concepts:


- Call
- Arguments
- Return
- recursion
- Overload

Languages ​​supporting this paradigm:


As the main:

- C
- C ++
- pascal
- Object Pascal

As auxiliary:

- C #
- java
- Ruby
- Python
- javascript

Partially supported:
- Early Basic

It is worth noting that several entry points from all these languages ​​are supported only in Python.

Modular programming



Once again, the increasing complexity of programs forced developers to share their code. This time the procedures were not enough and this time a new concept was introduced - the module.

Looking ahead, I would say that the modules were also unable to contain the increasing complexity of the software at an incredible speed, and later packages appeared (this is also modular programming), classes (this is OOP), templates (generalized programming).

The program described in the style of modular programming is a set of modules. What is inside, classes, imperative code or pure functions is not important.

Thanks to the modules for the first time in programming a serious encapsulation appeared - it is possible to use any entities inside the module, but not show them to the outside world.

Key points:


A module is a separate named entity of a program that combines other program units with similar functionality.

For example, a List.mod file that includes the List class.
and functions for working with it is a module.

The Geometry folder containing the Shape, Rectangle and Triangle modules is also a module, although some languages ​​share the concept of a module and a package (in such languages ​​a package is a set of modules and / or a set of other packages).

Modules can be imported (connected) in order to use the entities declared in them.

Basic concepts:


- Module
- Importing

Generated concepts:


- Package
- Encapsulation

Languages ​​supporting this paradigm:


As the main:

- Haskell
- pascal
- Python

As auxiliary:

- java
- C #
- ActionScript 3

Partially supported:
- C / C ++

In some languages ​​for modules, separate abstractions are introduced, in others, for the implementation of modules, header files (in C / C ++), namespaces, static classes and / or dynamic link libraries can be used.

Instead of conclusion


In this article, I did not describe the object-oriented, generalized, and functional programming that is currently popular. Just because I have my own, rather radical opinion on this matter and I did not want to breed holivar. At least for now. If the topic turns out to be useful for the community, I plan to write several articles, setting out the basics of each of these paradigms in detail.

Also, I did not write about exotic paradigms, such as automaton, applicative, aspect / agent / component-oriented programming. I did not want to make an article very large and again, if the topic is in demand, I will write about these paradigms, perhaps in more detail and with examples of code.

Source: https://habr.com/ru/post/223253/


All Articles