Imperative programming
Imperative programming is a programming paradigm where code explicitly specifies how to perform tasks through a sequence of commands that modify program state. Rather than declaring desired outcomes, programmers write step-by-step operations that tell the computer exactly what to do.
This approach mirrors how humans naturally give instructions: "do this, then that, then check this expression." The programmer directly manipulates variables, loops, and control flow, building arrays and dictionaries, calling functions, and updating state throughout execution.
Imperative languages—like C, Java, Python, and JavaScript—dominate because they map closely to how computers physically operate. They contrast sharply with Functional programming, which emphasizes immutability and avoids state changes altogether.
The strength of imperative code lies in its clarity for sequential logic and performance optimization. The weakness is that managing complex state can become error-prone and hard to reason about, especially as programs grow. Many modern languages blend imperative and functional approaches, giving programmers flexibility to choose the right tool for each problem.
Related
Functional programming, Object-oriented programming, Declarative programming, Loop (programming), Variable (programming), Side effect (programming)