How similar AI assisted coding is compared to declarative coding
by lonelyjohner | 2026-01-31 14:37:01+00:00
After playing with AI-assisted coding tools for a couple of months, a pattern becomes hard to ignore.

At first, it feels like autocomplete on steroids. Then it starts to feel like pair programming. Eventually, something clicks: the way you think about writing code changes.

You stop obsessing over the exact control flow and start spending more time on:

* clearly describing the problem
* identifying edge cases upfront
* defining what "correct" actually means

That shift mirrors something we’ve already seen before in programming history.

---

## A Familiar Parallel

There’s a useful mental model for understanding AI coding tools:

> *AI‑assisted coding : human coding :: declarative programming : imperative programming*

This analogy isn’t perfect—but it’s surprisingly powerful.

Imperative programming is about *procedures*.
Declarative programming is about *intent*.

AI‑assisted coding pushes software development in the same direction declarative paradigms did: away from micromanaging execution, toward expressing goals and constraints.

---

## Imperative Coding: Telling the Computer How

Imperative code is explicit, linear, and mechanical:

```js
let sum = 0;
for (let i = 0; i < nums.length; i++) {
if (nums[i] % 2 === 0) {
sum += nums[i];
}
}
```

You specify:

* control flow
* intermediate state
* order of operations

This mirrors *traditional human coding*:

* Read requirements
* Decompose into steps
* Implement each step manually

The human is responsible for every decision: loops, branches, data flow.

---

## Declarative Coding: Stating What You Want

Now compare that to a declarative style:

```js
const sum = nums.filter(n => n % 2 === 0)
.reduce((a, b) => a + b, 0);
```

Here you describe:

* what qualifies (even numbers)
* what result you want (a sum)

You don’t care how iteration happens.

SQL, React, CSS, functional pipelines—all follow this pattern.

The system figures out execution details.

---

## AI‑Assisted Coding Is Declarative Human Input

When you use AI, your role subtly changes.

Instead of writing:

> “First do X, then Y, then Z…”

You write:

> “Given this context, implement a function that does *X*, respecting *Y* and *Z*.”

Example prompt:

> “Write a Go function that parses DNS trace output and builds a graph of resolution hops.”

That’s declarative.

You specify:

* intent
* constraints
* shape of the output

The AI fills in loops, conditionals, data structures.

Just like a SQL engine or React reconciler.

---

## Humans Move Up the Abstraction Ladder

With imperative coding, humans live at the execution layer.

With AI assistance, humans move upward:

* defining invariants
* describing interfaces
* naming concepts
* evaluating correctness

This is the same shift that happened with:

* assembly → C
* C → higher‑level languages
* manual DOM → React

AI doesn’t remove abstraction—it *adds another layer*.

---

## The New Skill: Prompting Is Specification Design

Good AI usage looks a lot like good declarative API design:

Bad prompt:

> “Write some code to do DNS stuff.”

Good prompt:

> “Given this input format, produce a deterministic DAG where each hop is a node; preserve ordering; handle NXDOMAIN explicitly.”

This mirrors:

* good SQL schema design
* good React component boundaries
* good FP type signatures

The better the spec, the better the output.

---

## AI Doesn’t Replace Imperative Thinking—It Compresses It

The imperative steps still exist.
They’re just compressed into the model.

You’re trading:

* line‑by‑line control
for
* higher‑level leverage

Just like calling `Array.map` instead of writing a loop.