skip to content

In a declarative description of desired state, what does stating the result rather than the steps buy you?

level: juniorimportance: must knowfreq 72%

answer

  1. the result, not the route
  2. who decides the order of work
  3. a set of facts, not a script
  4. second run over matching state
  5. control traded for latitude

basics

~20 s

Stating the result hands the evaluator the strategy: it derives which operations run, in what order, and whether any are needed. You gain re-runnability, ordering freedom and portability, and give up step-by-step control of how the work is done.

solid answer

~50 s

A declarative description names what must be true when the run finishes — which artifacts exist, with which properties — and leaves the engine to read the current state, compute the gap and decide the work. Three things fall out of that. The engine picks the order, so you maintain a set of facts rather than a script whose lines are coupled by position. A run over state that already matches performs no writes, so the same description is the create path, the repair path and the drift check. And the description survives a smarter engine, because the strategy was never yours to begin with. What you trade away is control of *how*: when the engine plans badly there is no line for you to reorder, only a fact to add or an escape hatch to drop into.

code

yaml · 12 lines
yaml
desired:
  - id: store
    kind: datastore
    size_gb: 20
  - id: api
    kind: service
    instances: 3
    version: "2026.09"
    needs: [store]
  - id: entry
    kind: address
    target: api

go deeper

for a junior

Be able to say the core swap in one sentence: you state the result you want and something else works out the steps. Then name one thing you gain (the same description repairs and creates) and one thing you lose (you do not choose the order).

for a middle

Explain the mechanism, not the slogan: the evaluator reads current state, computes the gap, and derives operations and their order. Say where the latitude ends — the escape hatch that accepts a literal step — and why format alone does not make a description declarative.

for a senior

Show you have operated one. Talk about recovering the plan the engine chose, spotting a dependency that was real but never declared, and deciding whether a slow plan is the engine's fault or a missing fact in your description.

for a principal

Frame it as a standard: which surfaces in your estate should be desired-state, what the team pays in diagnosis skill and vocabulary limits, and what rule governs escape hatches so that today's exception does not become the way everyone writes tomorrow.

## What "declarative" actually claims A description is **declarative** when it states the properties that must hold once the run finishes and leaves the choice of operations, their order, and their number to whatever evaluates it. The contrast is a **script**: a sequence of operations that, executed in the written order, is expected to leave the system in the state you wanted. Same destination, two different things written down — the script encodes a route, the declaration encodes an address. Crucially, "declarative" is a property of the **description**, not of the file format. A data file that lists steps 1..n and expects them applied in that order is an imperative program wearing a data syntax. A description written in a general-purpose language that states constraints and hands them to an evaluator is declarative. One test classifies most cases: **if I swap two lines that do not mention each other, does the meaning change?** If it does, position is meaning, and what you wrote is steps. ## What you hand to the evaluator Every bit of latitude below is something you stopped deciding: - **Which operations run** — create, modify, or nothing, chosen from the gap between current and desired. - **The order** — any order consistent with the dependencies it can see. - **How many times** — including zero, where reality already matches. - **Where and with how much concurrency** — independent work may proceed together. - **Which strategy** — the same description can be executed by a better planner next year. | Decision | Imperative script | Declarative description | |---|---|---| | Which operations run | fixed by the author, line by line | derived from current state versus desired | | Order of work | the written order | any order the dependencies permit | | A second run | repeats the operations | performs no writes where state matches | | A better strategy appears | every script must be edited | same description, new evaluator | | Diagnosing a bad plan | read the lines you wrote | reconstruct the plan the engine chose | ## What you get back 1. **A repair path for free.** Because the description says what should be true rather than what to do next, applying it to a half-built, drifted or freshly empty system is the same operation. You do not write "create" and "fix" twice. 2. **Diffs that read as intent.** A change to the description is a change in what you want, not a change in procedure, which is why review of declarative surfaces tends to be cheaper than review of the equivalent script. 3. **Ordering freedom and parallelism.** Independent items can be done in any order or at once without you arranging it. 4. **Portability.** The same statement of the result can be satisfied by different evaluators against different targets, because none of the strategy was baked in. 5. **Analysis before execution.** A statement of intent can be parsed, checked and diffed against reality before anything is touched; a script must largely be run to find out what it does. ## What it costs - **You cannot dictate the plan.** When the engine's choice is slow or badly ordered, the fix is indirect — add a fact it was missing, or leave the paradigm. - **Debugging goes through the engine.** The failing thing is a plan you did not write, so diagnosis starts with getting that plan out of the tool rather than reading your own lines. - **An expressiveness ceiling.** Anything the vocabulary cannot express pushes you toward an escape hatch that accepts a literal step. - **Performance is not automatic.** "The engine decides" is a promise about correctness of the end state, not about it choosing the cheapest route. - **A different mental model.** Readers must stop asking "what happens next" and start asking "what is true at the end", which is genuinely harder for people trained on procedures. ## Where the line actually falls Declarative is a spectrum, not a badge. Query languages state the rows wanted and leave access strategy to a planner. Markup states structure and leaves layout to a renderer. Build and deployment descriptions state artifacts and their dependencies and leave scheduling to a driver. Rule surfaces state what must hold and leave evaluation order to an engine. Every one of them ships an escape hatch — a place to name a strategy or run a literal step — precisely because no vocabulary covers everything its users need. Using the hatch is not a sin; forgetting that you used it is, because the properties you were enjoying (re-runnability, ordering freedom, a readable diff) stop at the hatch and become your problem again.

  • What do you give up compared with writing the steps yourself?
    Control of how. In a script you can reorder a line, batch two operations, or insert a wait exactly where you need it. In a description you can only change what you are asking for, or state a fact the engine was missing. Diagnosis also gets longer: the plan that failed is one the engine composed, so you have to recover it before you can reason about it.
  • Does a declarative description have no order of execution at all?
    It has one — the engine's — it just is not the author's. Real dependencies still constrain the work, so a store is built before the service that names it. What disappears is order-by-position: two items that do not reference each other may be done in either order, or at the same time, and nothing in the description says otherwise.
  • Is a description declarative because it is written in a data format?
    No. A data file whose entries are 'step 1, step 2, step 3', applied strictly in that order, is an imperative program in a data syntax; reordering it changes the meaning. Conversely, a statement of constraints written in a general-purpose language is declarative. The question is always whether position carries meaning, not what the file extension is.

You give a driver an address rather than turn-by-turn directions: the address stays correct when the roads change, and the driver may take a better route than the one you knew.

saying these in an interview costs you the question

  • Declarative just means the configuration lives in a data file
  • Declarative code has no order of execution at all
  • The engine always produces a faster plan than a hand-written script
  • A declarative description cannot be influenced by its author
  • Running the same description twice must duplicate the work
  • Declarative means the system never reads its current state