Procedural programming is sometimes used as a synonym for imperative programming (specifying the steps the program must take to reach the desired state), but can also refer (as in this article) to a programming paradigm based upon the concept of the procedure call. Procedures, also known as routines, subroutines, methods, or functions (not to be confused with mathematical functions, but similar to those used in functional programming) simply contain a series of computational steps to be carried out. Any given procedure might be called at any point during a program's execution, including by other procedures or itself.
Procedural programming is often a better choice than simple sequential or unstructured programming in many situations which involve moderate complexity or which require significant ease of maintainability. Possible benefits:
Especially in large, complicated programs, modularity is generally desirable. It can be achieved using procedures that have strictly defined channels for input and output, and usually also clear rules about what types of input and output are allowed or expected. Inputs are usually specified syntactically in the form of arguments and the outputs delivered as return values.
Scoping is another technique that helps keep procedures strongly modular. It prevents the procedure from accessing the variables of other procedures (and vice-versa), including previous instances of itself, without explicit authorization. This helps prevent confusion between variables with the same name being used in different places, and prevents procedures from stepping on each other's feet.
Less modular procedures, often used in small or quickly written programs, tend to interact with a large number of variables in the execution environment, which other procedures might also modify. The fact that lots of variables act as points of contact between various parts of the program are what make it less modular.
Because of the ability to specify a simple interface, to be self-contained, and to be reused, procedures are a convenient vehicle for making pieces of code written by different people or different groups, including through programming libraries.
(See Module (programming) and Software package.)
Some imperative programming forms, such as object-oriented programming, are not necessarily procedural.
More sophisticated forms of modularity are possible with object-oriented programming, which is a more recent invention. Instead of dealing with procedures, inputs, and outputs, object-oriented programs pass around objects. Computation is accomplished by asking an object to execute one of its internal procedures (or one it has inherited), possibly drawing on some of its internal state. Procedural to OOP may help understanding the difference using code.
The canonical example of a procedural programming language is ALGOL. A language in which the only form of procedure is a method is generally considered object-oriented rather than procedural, and will not be included in this list. This applies to C# and Java, but not to C++.
Працэдурнае праграмаванне | Prozedurale Programmierung | תכנות פרוצדורלי | Programowanie proceduralne | Процедурное программирование | 절차적 프로그래밍
This article is licensed under the GNU Free Documentation License.
It uses material from the
"Procedural programming".
Home Page • arts • business • computers • games • health • hospitals • home • kids & teens • news • physicians • recreation• reference • regional • science • shopping • society • sports • world