jargon

Comparison

DeclarativevsImperative

Declarative

you write down what should exist, submit it, and something else works out the steps — including that most of them are already done.

Describing the end state you want rather than the actions to reach it, and letting a controller compute the difference. Its defining property is that applying the same description twice is a no-op, which is what makes automation safe to re-run and re-run by default. The cost is a loss of directness: you cannot straightforwardly express 'do this once', and you have to learn to debug a system that is arguing with you rather than one that failed a step.

Full entry →

Imperative

one version says what the result should be and the other lists the steps, and only one of them can be optimised for you.

Imperative code specifies the steps; declarative code specifies the outcome and leaves the steps to something else — SQL, a build tool, a UI framework, a reconciliation loop. The gain is that the executor can change strategy without you rewriting anything; the loss is that you cannot see what it is doing when it is slow or wrong. Nearly every abstraction argument in this corpus is a version of this trade.

Full entry →

The difference

Imperative code specifies the steps; declarative code specifies the outcome and leaves the steps to something else — SQL, a build tool, a UI framework, a reconciliation loop. The gain is that the executor can change strategy without you rewriting anything; the loss is that you cannot see what it is doing when it is slow or wrong. Nearly every abstraction argument in this corpus is a version of this trade.

Entry: Declarative vs imperative

Related comparisons