Comparisons

Pairs that get conflated in real conversations, and a few that get treated as synonyms when one is a prerequisite for the other. Neither column wins — what decides is the change in front of you. Each record leads with the confusion, because the confusion is why the record exists.

Declarative vs Imperative Infrastructure as Code

What people get wrong about this pair

People believe declarative means "no order of operations" and "safe by construction". It means neither. The tool still computes and applies an ordered plan with real dependencies, and the plan can delete data — a renamed resource or a changed immutable field becomes destroy-then-create, which is exactly how a declarative apply drops a database. The real distinction is convergence: declarative tools can be re-run to reconcile drift, imperative scripts generally cannot be re-run safely. That property is worth a lot, and it is not the same as safety.

Declarative
Use it when

Use declarative when you want to describe the desired end state and let a tool compute the difference from what exists.

Imperative
Use it when

Use imperative when the change is a sequence of operations whose order and side effects matter, or when no declarative model exists for what you are doing.

DimensionDeclarativeImperative
What you writeThe desired end stateThe steps to reach it
Re-running itConverges — a no-op if reality already matchesOften unsafe; needs its own idempotence
DriftDetectable by diffing state against realityInvisible unless something else checks
PreviewA plan you can read before applyingUsually only what the script prints as it goes
Hard partUnderstanding what the computed plan will destroyKeeping the sequence correct as it grows
Fails byA rename or an immutable-field change becoming a replacementHalf-applied state after a step fails midway