Programming Paradigm - A Step by Step to Programmers

Posted in

Programming Paradigm - A Step by Step to Programmers
vinaykhatri

Vinay Khatri
Last updated on December 23, 2024

    A programming paradigm is an approach to writing code using different methods, which also include the problem-solving mechanism of a structure. When a programming language is designed, the developers set a structured method that the programmer needs to follow if he codes in that programming language. A programming paradigm is a concept that is used to set a methodology of writing code in a particular programming language.

    The programming Paradigm is mostly related to high-level programming languages, you must be heard of object-oriented programming (OOP) which is the most famous programming paradigm, OOPs are mostly used to solve real-world problems.

    Types of Programming Paradigm

    There are commonly two types of Programming paradigms in use:

    • Imperative Programming
    • Declarative Programming

    1. Imperative Programming

    If you have coded in C++, Python, Java, or any other high-level language, that means you have used imperative programming. In this programming approach, you may have noticed that the outcome of the program depends upon the steps. In simple words, the problem solving step by step. Here, in imperative programming, we use commands which define which would be the next step the compiler or interpreter should execute to run the complete program. Imperative programming is similar to cooking, first do this then do this, which means you cannot directly jump to a process until you finish the previous one.

    In imperative programming, the flow of the program control by the commands and statements, and the state of the program get changes continuously which affects the global state of the computation. The changing of state helps to achieve the goal and it makes the program more logical. There are two types of Imperative Programming:

    • Procedural Programming
    • Object-Oriented Programming.

    1. Procedural Programming

    Procedural programming is a type of Programming Paradigm, which is derived from Structured programming , programming which focuses on improving the clarity, quality, and development time of the computer program. It is also known as Imperative programming. It is based on the concept of the procedure call. The procedures are sometimes also referred to as routine subroutines and functions. It also follows the concept of functional programming which helps to fix a block of code and increase its reusability.

    In procedural programming the code of the program executes linearly with logical steps, it follows the top to bottom approach, the code is written first and considered executed with some conditions. The conditions are decided by the procedure calls. For example, if there are two functions in the program the main function executes first and the code will execute from top to bottom.

    2. Object-Oriented Programming

    In object-oriented programming, we use class and object to solve the problem. Here objects are the instances of the class and class is the blueprint of the solution. All the class operation performs on the object only, the main focus of object-oriented programming is on data rather than procedure or steps. Object-Oriented programming comes which many properties such as inheritance, data abstraction, polymorphism, etc, which increase the security of data and the reusability of code. Java, C++, and Python are some of the programming languages which support Object-Oriented programming.

    Advantages of Imperative Programming
    • It is easy to implement using code
    • Easy to understand the flow of the Program
    • Contain Loops, variables, class, etc.
    Disadvantages of Imperative Programming
    • A complex problem can not be solved using Imperative
    • Parallel programming is not possible,

    2. Declarative Programming

    It is just the opposite of imperative programming, here programmer has no control over the steps of the code, this programming is only concerned with the output of the program rather than the steps to reach the output. Here in Declarative programming rather than focusing on the steps to the outcome, we focus on the logic and output of the program.

    There are many languages that follow this type of programming paradigm such as regular expression, SQL, etc., these languages focus on the output rather than the steps or linear execution of steps. There are three types of Declarative Programming:

    • Functional Programming
    • Logic Programming
    • Database Processing.

    1. Functional Programming

    The Origin of functional programming is derived from mathematics, as we use different equations and functions in math, we have adopted the same concept and used it in programming languages to solve problems. These days each high-level programming languages support functional programming because it reduces the redundancy of code and increases the concept of reusability of code. Many times, we confused Procedural programming with Functional programming, but both are different and the main disparity is, the outcome of the same input.

    As we know, Functional Programming is completely adopted from Mathematic and like mathematics no matter what if the input is the same for a function the output would same too, but in Procedural programming, the output of the input depends upon the state of the programming, so here in Procedural programming the output of the same input may differ from state to state.

    2. Logic Programming

    Logic Programming is completely based on mathematical logic, where we need to follow some set of rules to get a result. Every programming language that supports Logic programming, has some facts and rules about some problem domain. Prolog, GHC , Parlog, Vulcan, Polka, Mercury, Fnil are examples of Logic programming.

    3. Database-Driven Programming

    This programming paradigm's main concern is Data and its organization. Database-driven programming mostly focuses on the creation, updating, deletion, and reading of data. These programs are built on imperative programming methodology but they follow declarative programming. SQL is an example of Database driven programming.

    Conclusion

    This brings us to the end of this article on programming paradigms. In general, a paradigm is a specific approach to solving problems, and a programming paradigm is an approach to solving problems using a specific programming language.

    Through this article, we have discussed five different types of programming paradigms, namely procedural, object-oriented, functional, logic, and database-driven. Feel free to share your queries in the comments section below.

    People are also reading:

    Leave a Comment on this Post

    0 Comments