# Procedural programming

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Procedural_programming
> Markdown URL: https://mediated.wiki/source/Procedural_programming.md
> Source: https://en.wikipedia.org/wiki/Procedural_programming
> Source revision: 1330558256
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

Computer programming paradigm

This article is about the computer programming paradigm. For the method of algorithmic content creation, see [Procedural generation](/source/Procedural_generation).

This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "Procedural programming" – news · newspapers · books · scholar · JSTOR (April 2008) (Learn how and when to remove this message)

**Procedural programming** is a [programming paradigm](/source/Programming_paradigm), classified as [imperative programming](/source/Imperative_programming),[1] that involves implementing the behavior of a [computer program](/source/Computer_program) as [procedures (a.k.a. functions, subroutines)](/source/Function_(computer_programming)) that call each other. The resulting program is a series of steps that forms a hierarchy of calls to its constituent procedures.

The first major procedural programming languages appeared c. 1957–1964, including [Fortran](/source/Fortran), [ALGOL](/source/ALGOL), [COBOL](/source/COBOL), [PL/I](/source/PL%2FI) and [BASIC](/source/BASIC).[2] [Pascal](/source/Pascal_(programming_language)) and [C](/source/C_(programming_language)) were published c. 1970–1972.

[Computer processors](/source/Computer_processor) provide hardware support for procedural programming through a [stack register](/source/Stack_register) and instructions for [calling procedures](/source/Subroutine#Jump_to_subroutine) and returning from them. Hardware support for other types of programming is possible, like [Lisp machines](/source/Lisp_machines) or [Java processors](/source/Java_processor), but no attempt was commercially successful.[*[contradictory](/source/Java_processor)*]

## Development practices

Certain [software development](/source/Software_development) practices are often employed with procedural programming in order to enhance quality and lower development and maintenance costs.

### Modularity and scoping

[Modularity](/source/Modularity_(programming)) is about organizing the procedures of a program into separate modules—each of which has a specific and understandable purpose.

Minimizing the [scope](/source/Scoping) of variables and procedures can enhance software quality by reducing the [cognitive load](/source/Cognitive_load) of procedures and modules.

A program lacking modularity or wide scoping tends to have procedures that consume many [variables](/source/Variable_(programming)) that other procedures also consume. The resulting code is relatively hard to understand and to maintain.

### Sharing

Since a procedure can specify a well-defined interface and be self-contained it supports [code reuse](/source/Code_reuse)—in particular via the [software library](/source/Library_(computing)).

## Comparison with other programming paradigms

### Imperative programming

Procedural programming is classified as an [imperative programming](/source/Imperative_programming), because it involves direct command of execution.

Procedural is a sub-class of imperative since procedural includes [block](/source/Block_(programming)) and [scope](/source/Scope_(computer_science)) concepts, whereas imperative describes a more general concept that does not require such features. Procedural languages generally use reserved words that define blocks, such as if, while, and for, to implement [control flow](/source/Control_flow), whereas [non-structured](/source/Non-structured_programming) imperative languages (i.e. [assembly language](/source/Assembly_language)) use [goto](/source/Goto) and [branch tables](/source/Branch_table) for this purpose.

### Object-oriented programming

Also classified as imperative, [object-oriented programming](/source/Object-oriented_programming) (OOP) involves dividing a program implementation into objects that expose behavior (methods) and data (members) via a well-defined interface. In contrast, procedural programming is about dividing the program implementation into [variables](/source/Variable_(programming)), [data structures](/source/Data_structure), and [subroutines](/source/Subroutine). An important distinction is that while procedural involves procedures to operate on data structures, OOP bundles the two together. An object is a data structure and the behavior associated with that data structure.[3]

Some OOP languages support the class concept which allows for creating an object based on a definition.

Nomenclature varies between the two, although they have similar semantics:

Procedural Object-oriented Procedure Method Record Object Module Class Procedure call Message

### Functional programming

The principles of modularity and code reuse in [functional](/source/Functional_programming) languages are fundamentally the same as in procedural languages, since they both stem from [structured programming](/source/Structured_programming). For example:

- Procedures correspond to functions. Both allow the reuse of the same code in various parts of the programs, and at various points of its execution.

- By the same token, procedure calls correspond to function application.

- Functions and their modularly separated from each other in the same manner, by the use of function arguments, return values and variable scopes.

The main difference between the styles is that functional programming languages remove or at least deemphasize the imperative elements of procedural programming. The feature set of functional languages is therefore designed to support writing programs as much as possible in terms of [pure functions](/source/Pure_function):

- Whereas procedural languages model execution of the program as a sequence of imperative commands that may implicitly alter shared state, functional programming languages model execution as the evaluation of complex expressions that only depend on each other in terms of arguments and return values. For this reason, functional programs can have a free order of code execution, and the languages may offer little control over the order in which various parts of the program are executed; for example, the arguments to a procedure invocation in [Scheme](/source/Scheme_(programming_language)) are evaluated in an arbitrary order.

- Functional programming languages support (and heavily use) [first-class functions](/source/First-class_function), [anonymous functions](/source/Anonymous_function) and [closures](/source/Closure_(computer_programming)), although these concepts have also been included in procedural languages at least since [Algol 68](/source/Algol_68).

- Functional programming languages tend to rely on [tail call optimization](/source/Tail_call_optimization) and [higher-order functions](/source/Higher-order_function) instead of imperative looping constructs.

Many functional languages, however, are in fact impurely functional and offer imperative/procedural constructs that allow the programmer to write programs in procedural style, or in a combination of both styles. It is common for [input/output](/source/Input%2Foutput) code in functional languages to be written in a procedural style.

There do exist a few [esoteric](/source/Esoteric_programming_language) functional languages (like [Unlambda](/source/Unlambda)) that eschew [structured programming](/source/Structured_programming) precepts for the sake of being difficult to program in (and therefore challenging). These languages are the exception to the common ground between procedural and functional languages.

### Logic programming

In [logic programming](/source/Logic_programming), a program is a set of premises, and computation is performed by attempting to prove candidate theorems. From this point of view, logic programs are [declarative](/source/Declarative_programming), focusing on what the problem is, rather than on how to solve it.

However, the [backward reasoning](/source/Backward_reasoning) technique, implemented by [SLD resolution](/source/SLD_resolution), used to solve problems in logic programming languages such as [Prolog](/source/Prolog), treats programs as goal-reduction procedures. Thus clauses of the form:

- H :- B1, …, Bn.

have a dual interpretation, both as procedures

- to show/solve H, show/solve B1 and … and Bn

and as logical implications:

- B1 and … and Bn implies H.

A skilled logic programmer uses the procedural interpretation to write programs that are effective and efficient, and uses the declarative interpretation to help ensure that programs are correct.

## See also

- [Declarative programming](/source/Declarative_programming)

- [Functional programming](/source/Functional_programming) (contrast)

- [Imperative programming](/source/Imperative_programming)

- [Logic programming](/source/Logic_programming)

- [Object-oriented programming](/source/Object-oriented_programming)

- [Programming paradigms](/source/Programming_paradigm)

- [Programming language](/source/Programming_language)

- [Structured programming](/source/Structured_programming)

- [SQL procedural extensions](/source/SQL#Procedural_extensions)

## References

1. **[^](#cite_ref-1)** ["Programming Paradigms"](https://cs.lmu.edu/~ray/notes/paradigms/).

1. **[^](#cite_ref-:0_2-0)** "Welcome to IEEE Xplore 2.0: Use of procedural programming languages for controlling production systems". *Proceedings. The Seventh IEEE Conference on Artificial Intelligence Application*. [IEEE](/source/IEEE). [doi](/source/Doi_(identifier)):[10.1109/CAIA.1991.120848](https://doi.org/10.1109%2FCAIA.1991.120848). [S2CID](/source/S2CID_(identifier)) [58175293](https://api.semanticscholar.org/CorpusID:58175293).

1. **[^](#cite_ref-3)** Stevenson, Joseph (August 2013). ["Procedural programming vs object-oriented programming"](http://neonbrand.com/procedural-programming-vs-object-oriented-programming-a-review/). neonbrand.com. Retrieved 2013-08-19.

## External links

v t e Programming paradigms Imperative Structured Jackson structures Block-structured Modular Non-structured Procedural Programming in the large and in the small Design by contract Invariant-based Nested function Object-oriented Class-based, Prototype-based, Object-based Agent Immutable object Persistent Uniform function call syntax Declarative Functional Recursive Anonymous function (Partial application) Higher-order Purely functional Total Strict GADTs Dependent types Functional logic Point-free style Expression-oriented Applicative, Concatenative Function-level, Value-level Monad Dataflow Flow-based Reactive (Functional reactive) Signals Streams Synchronous Logic Abductive logic Answer set Constraint (Constraint logic) Inductive logic Nondeterministic Ontology Probabilistic logic Query Domain- specific language (DSL) Algebraic modeling Array Automata-based (Action) Command (Spacecraft) Differentiable End-user Grammar-oriented Interface description Language-oriented List comprehension Low-code Modeling Natural language Non-English-based Page description Pipes and filters Probabilistic Quantum Scientific Scripting Set-theoretic Simulation Stack-based System Tactile Templating Transformation (Graph rewriting, Production, Pattern) Visual Concurrent, parallel Actor-based Automatic mutual exclusion Choreographic programming Concurrent logic (Concurrent constraint logic) Concurrent OO Macroprogramming Multitier programming Organic computing Parallel programming models Partitioned global address space Process-oriented Relativistic programming Service-oriented Structured concurrency Metaprogramming Attribute-oriented Automatic (Inductive) Dynamic Extensible Generic Homoiconicity Interactive Macro (Hygienic) Metalinguistic abstraction Multi-stage Program synthesis (Bayesian, by demonstration, by example, vibe coding) Reflective Self-modifying code Symbolic Template Separation of concerns Aspects Components Data-driven Data-oriented Event-driven Features Literate Roles Subjects Comparisons/Lists Comparison (multi-paradigm, object-oriented, functional), List (OO, by type)

---
Adapted from the Wikipedia article [Procedural programming](https://en.wikipedia.org/wiki/Procedural_programming) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Procedural_programming?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
