Programming paradigms, Sounds very pretentious right? The term programming paradigm refers to the style or way of programming.
For example, If I ask our readers to multiply 328 with 4 and tell me the result. Each of them will have their style or technique of solving this problem. For example, look at the below diagram. I have listed a few of the strategies one can use to do this long multiplication.
Like how we have various techniques to help us solve the above problem, the programming paradigms offer different tools and approaches that can help us solve problems using programming languages.
In other words, Programming paradigms are the concepts to which the methodology of programming adheres. This helps us solve problems in terms of machine code at a much-heightened level.
It is possible to solve the same problem using different paradigms, Just how we solved a long multiplication problem with various techniques in the above example. However, certain types of problems fit more naturally to specific paradigms.
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.Martin Fowler
It is essential to learn programming paradigms. Learning programming paradigms will help you understand the very principles upon which the programming languages are built. Good knowledge of programming paradigms will make learning programming languages much easier & also help us make the best use of them. In my opinion, learning a new programming language is nothing but learning its syntax and vocabulary. Before we even start learning any programming language, it is important to know the programming paradigms.
There are broadly two types of programming paradigms, an imperative and a declarative. There are several other paradigms that are influenced by these two—for example, Object-Oriented Programming, functional programming.
Let’s talk a bit about these two primary types, Imperative and Declarative. Imagine you went to a restaurant and wanted to order a spicy Biryani. You could just tell the server to make the Biryani spicier, or you can give him the recipe to make the Biryani spicy. In the first case, You are just telling the server to bring what you want. It is up to the server & chef how they want to make Biryani spicier for you. Whereas in the second case, you are giving all the required instructions or the commands to the server ( thereby to the chef) to make the Biryani Spicier. The first one is the declarative approach and the second one imperative approach.
Imperative – How you want it done
Declarative – What you want done
feature image credits: freepik