Procedural programming, as the name suggests, is based on the concept of procedural call. To understand it more deeply, we should first know what procedural call means.
Procedures, also known as routines, subroutines, or functions, simply contain a series of computational steps to be carried out. Let’s see an example of the procedure
1 2 3 4 5 6 7 8 |
#Procedure def add_list(my_list): Total = 0 for x in my_list: Total += x return Total # Procedure Call add_list([1,2,3,4]) |
Procedure calls are modular and are bound by scope. It means we break the program into independent, interchangeable small pieces known as modules such that each module contains everything necessary to execute. Each module is composed of one or more procedures.
Procedural programs may possibly have multiple levels or scopes, with subprograms defined inside other subprograms. Scoping helps to keep the procedures modular and prevents/allows the procedure, from accessing the variables of other procedures.
Procedural programming falls under the imperative umbrella which means that procedural inherits the properties of the imperative paradigm. Procedural programming uses a linear or top-down approach.
Pros: easier to read and more maintainable, more flexible, allows modules to be used again in the form of code libraries.
Cons: this approach may not use hardware efficiently when tackling complex problems because of side effects (may not run parallelly)
In short, procedural programming means breaking the program into modules and using the imperative approach. If we take away the imperative nature from procedural, then it becomes same as Functional.
Now, you might have got some feeling about the Procedural programming. Hope you enjoy reading.
If you have any doubt/suggestion please feel free to ask and I will do my best to help or improve myself. Good-bye until next time.