We can write almost any code in any language in different ways. You can split the code into functions differently, name variables in different ways, or change the nesting depth of conditional constructs. These are all metrics of code quality and the individual components that make coding style.
However, coding style has almost no effect on the specific task and the solution architecture. We determine these properties by choosing the programming paradigm.
A programming paradigm is a set of ideas about how to solve a problem. We start applying the paradigm even before we start writing code. The code in a particular language merely allows us to write our thoughts in a program with a greater or lesser degree of convenience.
An experienced programmer knows how to:
- Think in the right way and various paradigms
- Apply different paradigms
- Choose the right paradigm for specific tasks
- Write their thoughts in code in different programming languages
We can say that the paradigm is suitable for any programming language when you don't need to battle with the language and change your approach to solve a problem. If the paradigm fits the language, the programmer writes down their thoughts as they are.
Python and most modern high-level programming languages are considered multiparadigms. In other words, you can use many different paradigms. It won't be any less convenient.
C and other low-level languages cannot afford this freedom because code in these languages must be efficient. In these languages, solutions are tied as much as possible to how the task is understood by the computer, not by the developer.
Imperative programming
Let's imagine that we need to solve a complex problem. We cannot solve it in one computer action, so we describe a sequence of steps to be performed.
We break down the broad steps into smaller ones until the interpreter or compiler of the chosen language can understand each step. Simply put, we think through and describe how to achieve the desired result. This description of a sequence of steps is called imperative programming.
Imperative programming involves changing the state of the computer. Large programs constantly modify global and local variables:
- Write things to the disk
- Send and receive from the network