# Procedural Programming
## Paradigms — The Codex Coding
**URL:** https://thecodex.expert/coding/paradigms/procedural/
**Type:** paradigm | **Confidence:** high | **Last verified:** 2026-06-01

---
## CANONICAL DEFINITION
Procedural programming is a programming paradigm derived from structured programming, in which a program is composed of procedures (named sequences of statements) that operate on shared or passed data, executing in an explicit sequence determined by control flow statements such as conditionals and loops, with program state held in mutable variables.

---
## CONCEPT RELATIONSHIP MAP
**Requires first:** How Computers Work · Compilation
**Enables:** Functions · Scope · Control Flow · Variables · Object-Oriented Programming (evolution from)
**Commonly confused with:** Imperative programming (procedural is a subset — all procedural is imperative, not all imperative is procedural)

---
## CURIOUS LEVEL
Programs as sequences of instructions. Procedures are named, reusable blocks called by name. Call stack tracks return addresses. State held in variables. Control flow: sequence (default), selection (if/else), iteration (for/while). Structured programming (Dijkstra, 1968): no arbitrary GOTO — only these three constructs needed. Primary languages: C, Pascal, Bash.

## EXPLORING LEVEL
Imperative vs. procedural: imperative = specifying how; procedural adds named subroutines + call stack. Stack frames: return address + local variables + arguments. Stack overflow from infinite recursion. Scope: global (visible everywhere, dangerous), local (destroyed on return, safe), parameters (by value or pointer in C). Böhm & Jacopini (1966): sequence + selection + iteration are sufficient for any computation. System V AMD64 ABI: first 6 args in registers RDI/RSI/RDX/RCX/R8/R9.

## COMMONLY CONFUSED
- Procedural ≠ imperative (procedural is a specific subset)
- Functions in C ≠ mathematical functions (can have side effects, read global state)
- Procedural is not outdated — Linux kernel, embedded systems, most OS code is procedural C

## DEEP DIVE LEVEL
Structured programming theorem (Böhm & Jacopini, 1966): any partial recursive function computable by a flowchart can be computed with only sequence, if-then-else, and while-do. Proof uses the Böhm-Jacopini transformation (auxiliary boolean variables). Dijkstra (1968) showed GOTO prevents establishing invariants — structured programs have well-defined invariant checkpoints. ABI governs calling convention, register use, stack layout, and enables cross-language calls.

## SOURCES
1. Dijkstra, E. W. (1968). Go To Statement Considered Harmful. CACM 11(3).
2. Böhm, C. & Jacopini, G. (1966). Flow diagrams, Turing machines. CACM 9(5).
3. Kernighan, B. W. & Ritchie, D. M. (1988). The C Programming Language (2nd ed.). Prentice Hall.
4. Dijkstra, E. W. (1972). The Humble Programmer. CACM 15(10).

*The Codex Coding — thecodex.expert/coding/ — Free forever — Mumbai, India*
