DELAPARRA
Index
Color
NL
Category: Programming paradigms

Imperative

Explained by Updated

What is Imperative?

Imperative: You write explicit instructions for the machine: "do this, then do this, then check this condition, then loop". The control flow is up to you. Imperative code tells the computer exactly what to do, step by step. Set a counter to zero, loop over the orders, check each status, add to the total, return the result. You control the flow.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Imperative

How is Imperative used in practice?

Most programming starts here, and it maps closely to how processors work. It is explicit and easy to step through in a debugger.

What should you keep in mind with Imperative?

The downside is that the intent can get lost in the bookkeeping. A ten-line loop that sums paid orders says less clearly what it does than $orders->where('paid', true)->sum('total'). Good code mixes both styles: declarative where the intent matters most, imperative where you need fine control over performance or a specific sequence of side effects, such as calling an external API in a set order.

At a glance

CategoryProgramming paradigms
Explained by
Updated

More Programming paradigms terms

All terms starting with I

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.