Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
― Martin Fowler
When programming, complexity is always the enemy. Programs with great complexity, with many moving parts and interdependent components, seem initially impressive. However, the ability to translate a real-world problem into a simple or elegant solution requires a deeper understanding.
While developing an application or solving a simple problem, we often say “If I had more time, I would have written a simpler program”. The reason is, we made a program with greater complexity. The less complexity we have, the easier it is to debug and understand. The more complex a program becomes, the harder it is to work on it.
Managing complexity is a programmer’s main concern. So how do programmers deal with complexity? There are many general approaches that reduce complexity in a program or make it more manageable. One of the main approaches is a programming paradigm. Let’s dive into programming paradigms!
Introduction to programming paradigms
The term programming paradigm refers to a style of programming. It does not refer to a specific language, but rather it refers to the way you program.
There are lots of programming languages that are well-known but all of them need to follow some strategy when they are implemented. And that strategy is a paradigm.
The types of programming paradigms
Imperative programming paradigm
The word “imperative” comes from the Latin “impero” meaning “I command”.
It’s the same word we get “emperor” from, and that’s quite apt. You’re the emperor. You give the computer little orders to do and it does them one at a time and reports back.
The paradigm consists of several statements, and after the execution of all of them, the result is stored. It’s about writing a list of instructions to tell the computer what to do step by step.