Field Study · Programming Paradigms × AI Coding Agents
Six Weird Ways to Build the Same Web App
Almost every modern web app splits your brain across a browser framework, a JSON API, an ORM, and a database. What happens when you hand an AI coding agent six paradigms that collapse, invert, or compile away those layers — and then force it through seven brutal day-2 maintenance changes?
48/48 milestones passed — every baseline (B01–B10) and every evolution (C1–C7) compiled, ran, and passed tests.
28.7 min
Fastest total stack: Phoenix LiveView (13.2m baseline + 15.5m across all 7 evolutions, just 4 repair loops).
0 loops
Gleam DSL baseline compiled & passed all 10 acceptance criteria on the first try; C2 needed 0 view edits.
2.4×
Slowest vs. fastest spread — Electric Clojure v3 took 67.7 min, proving tooling stability beats clever alpha magic.
Section 01 · Primer for the Unfamiliar
What Actually Happens When You Click “Save”?
If you have never built a web application, here is the secret behind 90% of software complexity: almost every interactive site is a CRUD app (Create, Read, Update, Delete), and modern teams usually split it into five separate worlds that must constantly translate into one another.
Why this matters for AI agents: When you add a single field like due_date or a status like blocked in a mainstream stack, an agent has to update SQL migrations, ORM models, backend validators, JSON serializers, TypeScript types, client cache invalidation, and form dropdowns in lockstep. Forget one seam and the app compiles cleanly — then quietly breaks in production.
Each of our six “weird” paradigms asks a provocative question: what if we delete one or more of those boxes entirely? Click any card below to jump straight to its deep walkthrough:
To compare paradigms fairly — without letting the agent cheat by quietly dropping React or a REST API in the back door — every experiment lived in its own isolated Git repository inside a single 3 GiB VM and followed a frozen specification called Project Pulse.
The Frozen Baseline Contract (B01–B10)
Project Pulse is a project-and-task tracker small enough to inspect completely, yet rich enough to stress every architectural seam: projects have validated names/descriptions and cascade-delete their tasks with confirmation; tasks have titles, enums (status, priority), cross-project moves, combined filters, live done / total progress (including 0 / 0 empty states), idempotent seed data across server restarts, non-reusable IDs, and strict HTML escaping against XSS (<script>alert(1)</script>).
Generating a greenfield CRUD app is easy for modern LLMs. What separates a genuinely agent-friendly architecture from a demo is day-2 evolution: changing a live system without breaking existing tests or wiping user data. After committing each passing baseline to main, the agent received seven evolution challenges one at a time, committing after each:
C1 · Schema Evolution
Optional Due Dates
Add ISO YYYY-MM-DD due dates with local-date overdue/upcoming/none filters; reject calendar-invalid dates like 2026-02-30.
Tests: Data-preserving migrations without resetting existing records.
C2 · Changed Invariant
Blocked Status
Add blocked to all forms and filters while ensuring blocked tasks never count as done in progress calculations.
Tests: Whether enums, DB constraints, and UI dropdowns stay synchronized.
C3 · Atomicity
Duplicate Project
Clone a project as Original (copy) plus 0, 1, or many tasks with new IDs — all-or-nothing with zero partial clones on failure.
Tests: Multi-record transactions and rollback ergonomics.
C4 · Derived Query
Live Project Dashboard
Show total, done, blocked, and % complete (0% if empty) per project, staying fresh after every move or delete.
Tests: Derived state, SQL views/aggregates, and UI synchronization.
C5 · Hard Mode
Authorization Boundary
Add local demo accounts alice and bob. Crafted requests must never read, edit, move, or delete another owner’s records.
Tests: Real server-side trust boundaries vs. fake client-side filtering.
C6 · Operational Stress
Malformed & Concurrent Storms
Harden against duplicate rapid submits, huge/invalid IDs, and overlapping moves/deletes under real parallel load.
Tests: Idempotency, optimistic locks, and runtime concurrency limits.
C7 · Product Polish
Accessibility & Footprint
Full keyboard nav, ARIA live error announcements, focus management, and 375px mobile layout — without adding an SPA framework.
Tests: Whether the paradigm stays pleasant under routine UX polish.
Section 03 · Empirical Results
The Interactive Scoreboard
Every single stack achieved 10/10 baseline acceptance tests and 7/7 evolution challenges. The real story is in how long each architecture fought back — measured by wall-clock minutes and compile/test repair loops.
End-to-End Effort Comparison
Evolution Heatmap: 6 Paradigms × 7 Challenges
Click any of the 42 cells to inspect exact notes · m = minutes, L = repair loops
Paradigm
C1 Due Date
C2 Blocked
C3 Duplicate
C4 Dashboard
C5 Auth
C6 Storms
C7 A11y
Section 04 · Deep Walkthroughs
Inside All Six Approaches
Each dossier explains the paradigm from first principles, diagrams how data moves across the wire, shows real code lifted straight from our finished repositories, and highlights what surprised us during evolution.
“What if interactive apps felt like SPAs, but the browser only received tiny HTML diffs?”
Total Time28.7 min
C1–C7 Evo15.5 min
Loops2 + 2
Test Suite59 in 0.4s
How it works (for the unfamiliar)
Normally, rich web interfaces run a giant JavaScript program inside your browser that talks to a backend via JSON. Phoenix LiveView flips that around: when you open the page, the server spawns a lightweight Erlang/Elixir process (costing a few kilobytes of RAM) dedicated to your browser tab, connected over a persistent WebSocket. When you click a button or type in a filter, the browser sends a tiny event; the server runs Elixir, updates PostgreSQL, computes only the changed parts of the HTML template, and ships a surgical patch back to the DOM.
What happened under evolution
Fastest evolution in the lab: C2 (blocked) took 47 seconds, C3 (duplicate) took 43 seconds, and C1–C5 had zero repair loops.
Sub-second full-UI tests:Phoenix.LiveViewTest clicks buttons, submits forms, tests auth denial, and verifies PubSub multi-tab sync in 0.4 seconds without booting a browser.
Real database muscle: Ecto migrations, Ecto.Multi atomic rollbacks, optimistic_lock, and ordered SELECT ... FOR UPDATE locks survived real multi-connection Task.async deadlock tests.
Minimal JS footprint: Baseline used 0 lines of custom JS; C7 added just 45 lines of vanilla JS for focus trapping (+1.4 KB).
Why agents crush this: Schema, enum, validation, optimistic lock version, and idempotency key live in one crisp pipeline — and mix compile --warnings-as-errors catches typos before a test even starts.
Implication for teams: If you are building SaaS, internal tools, or dashboards with AI agents today, Phoenix LiveView gives you real-time UX and PostgreSQL rigor without paying the React + REST split-brain tax.
Live capture (Phoenix LiveView): Server-rendered HEEx template with real-time PubSub dashboard, inline duplicate/edit/delete controls, and local demo account switcher.
SWI-Prolog + htmx: Business Rules as Executable Logic
“Don’t write if-statements — declare what must be true and let the engine prove it.”
Total Time32.6 min
Baseline9.8 min
Loops5 + 2
Assets20.4 KB gz
How it works (for the unfamiliar)
Prolog (1972) is a logic programming language: instead of giving step-by-step instructions, you state facts (“Task 4 belongs to Project 1”) and logical rules (“Alice can move Task T to Project P if Alice owns T’s current project AND Alice owns P”). Paired with htmx — a tiny 16 KB library that lets HTML buttons swap fragments of the page directly from server responses — you get an interactive app with no ORM, no SQL, no JSON API, and no bundler.
What happened under evolution
Fastest baseline (9.8 min) & only 2 evolution repair loops: Zero build pipeline meant instant edit-and-test cycles.
Effortless additive schema evolution: Instead of altering old records in C1, C5, and C6, Prolog simply added new persisted predicates (task_due_date_fact/2, project_owner_fact/2, entity_version_fact/3). Pre-C1 journals replayed cleanly with zero migration script.
The real ceiling: SWI-Prolog’s built-in library(persistency) journals one fact at a time — it has no crash-safe WAL rollback on abrupt SIGKILL or multi-process locking, so we had to wrap mutations in an explicit pulse_db mutex and be honest about single-process limits.
Look at orphan_project_owner/1: Because Prolog is relational, you can write negative invariants as executable queries and assert in tests that no orphan solution exists.
Implication for teams: Even if you never deploy Prolog in production, pairing declarative policy rules (like OPA/Cedar/Datalog) with server-rendered htmx fragments eliminates huge amounts of glue code.
“Wait — why do we even have an application server between HTTP and PostgreSQL?”
Total Time40.8 min
Baseline13.0 min
Loops1 + 3
Payload25 KB gz
How it works (for the unfamiliar)
PostgREST is a lightweight standalone binary that turns a PostgreSQL database directly into an HTTP API. Most people use it to serve JSON — but PostgREST also supports custom media types. By defining a PostgreSQL domain literally named api."text/html", our SQL functions returned full HTML pages and htmx fragments directly from inside the database. There is no Python, no Node, no Go, and not even a separate static file server.
What happened under evolution
Shockingly clean baseline (1 repair loop): Because data invariants, foreign keys, cascades, and transactions all live in PostgreSQL natively, C1–C5 had zero repair loops.
Zero-drift transactions: Every PostgREST RPC executes inside a single PostgreSQL transaction — so updating a task and rendering its updated OOB dashboard view happen atomically on the exact same snapshot.
Where it got weird: Browsers send Accept: */* for <script src>, which made PostgREST return JSON-quoted JavaScript. We solved it by inlining vendored htmx.min.js into api.index(). And by C7, HTML-in-SQL grew to 3,859 lines of PL/pgSQL — powerful, but painful to format and maintain visually.
-- Derived dashboard view — zero app-server mathCREATE OR REPLACE VIEW private.project_dashboard ASSELECT p.id, p.name,
count(t.id)::int AS total_tasks,
count(t.id) FILTER (WHERE t.status = 'done')::int AS done_tasks,
count(t.id) FILTER (WHERE t.status = 'blocked')::int AS blocked_tasks,
CASE WHEN count(t.id) > 0THEN round((count(t.id) FILTER (WHERE t.status = 'done')::numeric
/ count(t.id)::numeric) * 100)::int
ELSE0END AS percent_complete
FROM private.projects p
LEFT JOIN private.tasks t ON t.project_id = p.id
GROUP BY p.id, p.name ORDER BY p.id ASC;
-- SQL itself sets HTTP status & htmx headers!PERFORM set_config('response.status', p_status::text, true);
PERFORM set_config('response.headers',
jsonb_build_array(jsonb_build_object('HX-Retarget', '#feedback-banner'))::text, true);
Look closely: PostgreSQL sets HX-Retarget HTTP headers and returns api."text/html" straight to the browser, while REVOKE ALL keeps raw tables unreachable via HTTP.
Implication for teams: Don’t render HTML inside PL/pgSQL for real apps — do push constraints, views, ON DELETE CASCADE, and atomic invariants down into PostgreSQL instead of duplicating them weakly in app code.
Live capture (PostgreSQL + PostgREST + htmx): Rendered straight out of PostgreSQL SQL functions with vendored htmx inlined into api.index() — no web app server at all.
“Don’t write CRUD boilerplate six times — write a tiny schema language that generates it deterministically.”
Total Time~43.2 min
Base Loops0 loops
C2 View Edits0 edits
Test Suite41 in 0.3s
How it works (for the unfamiliar)
Gleam is a friendly, statically typed functional language that compiles to the Erlang VM (BEAM). Rather than hand-coding Project Pulse directly, this experiment asked the agent to invent a miniature Domain-Specific Language (DSL) called app.pulse — just 17 lines long — plus a real lexer, parser, validator, and code generator that compiles those 17 lines into SQLite DDL, Gleam domain types, repositories, Lustre HTML views, Wisp HTTP handlers, and unit tests.
What happened under evolution
Zero baseline repair loops: Gleam’s clean, small syntax and strict type checker let the agent build a working compiler + generator + web app with 0 compiler or test loops.
The C2 magic moment: Adding blocked was a 1-word edit in app.pulse; running codegen updated SQL, domain, and repo with zero manual edits to any view file. In C5, adding a server_managed keyword to the DSL automatically kept owner out of generated client forms!
The hidden cost: Building a bespoke compiler for just two entities meant maintaining ~3,900 lines of generator code, and SQLite’s inability to alter CHECK constraints in-place required explicit table-rebuild migrations (and even exposed SQLite’s sneaky 3-valued CHECK(NULL) trap on invalid dates!).
06-gleam/app.pulse (the entire executable schema!)
17 lines → 1,659 lines of verified code: Running gleam run -m project_pulse/codegen twice produces 0 bytes of git diff — guaranteeing the spec and the running app can never disagree.
Implication for teams: Don’t invent a custom DSL for a 2-table app — do adopt schema-first codegen (SQLc, Prisma, Drizzle, OpenAPI, Protobuf) whenever you have 10+ entities, because AI agents excel when one canonical schema drives everything else.
http://127.0.0.1:4106 — Gleam 1.19 + Wisp/Mist + Lustre SSR + SQLiteClick to zoom & compare
Live capture (Gleam DSL Generator): Lustre server-rendered HTML driven by app.pulse codegen, showing generated overdue/upcoming due-date pills and zero-JS form workflows.
Rank #5 Overall (#2 in Evolution!) · Experiment 01 · Pure Functional Full-Stack
Lamdera / Elm: One Typed Universe, Zero Glue
“What if frontend, backend, network wire, and database were all just Elm types?”
Total Time~45.5 min
C1–C7 Evo16.5 min
Loops9 + 4
JS Ports0 lines
How it works (for the unfamiliar)
Elm is famous for “no runtime exceptions in practice” — its compiler forces you to handle every single possible state, edge case, and error explicitly. Lamdera extends Elm across the network: you define four types (FrontendModel, BackendModel, ToBackend, ToFrontend), and Lamdera automatically persists your BackendModel to disk and auto-generates binary serializers for every message. No JSON, no REST endpoints, no SQL, no ORM.
What happened under evolution
Nearly tied Phoenix on evolution (16.5 min, 4 loops!): Once the baseline harness was up, the Elm compiler acted like a laser-guided checklist. C2 (blocked) took 54s; C4 (dashboard) took 52s; C5 (auth) took 2.2m — all with 0 repair loops.
Compiled migrations: Instead of fragile SQL scripts, schema changes are pure Elm functions (V1BackendModel -> V2BackendModel) — if you forget to migrate a field, the code refuses to compile.
The catches: Baseline setup was painful (~29m, 9 loops with Codex, mostly fighting headless Chromium/Playwright on Ubuntu 26.04), production hosted Evergreen verification requires Lamdera’s cloud remote, and an in-memory backend model doesn’t fit billion-row analytics workloads.
01-lamdera/src/Types.elm & src/Migrations.elm
typeStatus = Todo | Doing | Done | BlockedtypeOwner = Alice | Bob-- Your entire server "database" & session store is one typed record:type aliasBackendModel =
{ projects : DictIntProject
, tasks : DictIntTask
, nextProjectId : Int
, nextTaskId : Int
, sessions : DictSessionIdOwner
, seenRequests : DictSessionId (ListString)
}
-- Schema migration is a compiler-verified pure function:migrateV1ToV2 : V1BackendModel -> V2BackendModel
Why agents love Elm during maintenance: Zero runtime undefined is not a function, zero hand-written JSON codecs, and exhaustive case checking turns every requirement change into exact compiler diagnostics.
Implication for teams: Pure domain cores + exhaustive sum types (in Elm, Gleam, Rust, or strict TypeScript) are the strongest anti-hallucination guardrail you can give an AI coding agent.
http://127.0.0.1:8000 — Lamdera 1.4 / Elm 0.19.1Click to zoom & compare
Live capture (Lamdera / Elm): Pure Elm UI with compiled Evergreen-style state migrations, scoped OwnerSnapshot reads, and Lamdera’s live dev emulator badge in the bottom-left.
Electric Clojure v3: The Compiler Crosses the Network
“Write browser buttons and server database calls inside the same lexical scope.”
Total Time67.7 min
C1–C7 Evo41.8 min
Loops3 + 8
JS Bundle230 KB gz
How it works (for the unfamiliar)
Electric Clojure is the most mind-bending paradigm of the six. Inside a single .cljc file, you tag expressions with (e/client ...) and (e/server ...). You can literally nest a server SQLite write inside a browser button’s click handler. At compile time, Electric’s macro compiler slices your program into a reactive client half (ClojureScript) and server half (JVM Clojure), automatically wiring up streaming WebSocket diffs between them.
Why it was the hardest for an agent
Genuine magic when it worked: Watching one server atom (e/watch store/!db-version) gave automatic multi-tab realtime push with zero REST routes, zero JSON, and zero fetch().
Alpha & macro friction multiplied every step: Electric v3’s :dev mode blocked on an interactive Hyperfiddle email activation prompt, forcing 20–27s :prod release rebuilds on every single edit.
Non-standard semantics tripped agent intuition: Sibling expressions inside Electric’s do run concurrently; deep DOM trees overflowed the macroexpander stack (needing -Xss4m); and unmounting a delete dialog canceled its own in-flight click handler in C6!
02-electric/src/project_pulse/app.cljc
;; Server-only reactive binding from HttpOnly cookie — never sent to browser
(e/declare session-token)
;; Browser <select> directly invokes a server SQLite transaction inline!
(dom/select (dom/props {:class "quick-status-select" :value (:status task)})
(e/for-by identity [st domain/valid-statuses]
(dom/option (dom/props {:value st}) (dom/text st)))
(e/for [[t new-st] (dom/On-all "change" #(.. % -target -value))]
(let [res (e/server
(let [tok session-token]
(e/Offload #(store/update-task-for-session! tok tid {:status new-st}))))]
(e/client (finish-inline-task-op! t !ui res "Updated.")))))
Look at lines 9–12: No URL, no HTTP verb, no JSON serializer. The client change event flows across the network directly into a Clojure database call, and the return value flows straight back into client UI state.
Implication for teams: Brilliant ideas still lose to boring execution when an agent faces slow rebuilds (25s vs 0.3s), dynamic typing, alpha API drift, and non-obvious macro semantics.
http://127.0.0.1:4102 — Electric Clojure v3 + Jetty WebSocket + SQLiteClick to zoom & compare
Live capture (Electric Clojure v3): Reactive browser DOM compiled directly alongside server SQLite calls in app.cljc, with automatic WebSocket push across tabs.
Section 05 · Interactive Comparison
Same Change, Six Worlds
The fastest way to feel the difference between programming paradigms is to look at the exact same requirement implemented in two different worlds side-by-side. Pick a challenge and choose any two stacks below:
Section 06 · Synthesis & Implications
Which Is Best for AI Agents — and How Do They Beat Mainstream Stacks?
Everyone assumes AI coding agents work best in whatever language has the most GitHub stars (React + TypeScript + Python/Node REST). Our experiment showed something sharper: architecture beats popularity.
Rule-heavy policy engines (Prolog) or DB-centric prototypes.
Electric Clojure v3 67.7m total · 11 loops
Zero (conceptual) Compiler-sliced WebSocket
Slow (25s build) + Playwright waits
Low Dynamic + macro-heavy
Alpha License gate & API drift
Research / adventurous Clojure teams willing to ride v3 alpha.
The Four Laws of Agent-Friendly Architecture
Even if your team writes TypeScript or Python every day, you can steal the exact properties that made Phoenix, Elm, and Gleam fly for AI agents:
Law 01 · Collapse the Seams
Every serialization boundary is an AI drift tax
When adding blocked took 47 seconds in Phoenix and 54 seconds in Elm, it wasn’t because Elixir is magic — it was because there was no separate REST DTO, Redux store, or React Query cache to forget. Prefer server-first stacks (LiveView, htmx, Remix, Next.js Server Actions) over split SPA + REST repos unless the UI truly requires it.
Law 02 · Compiler as Checklist
Strict exhaustive types beat runtime guesses
In Elm and Gleam, adding an enum variant made the compiler hand the agent a line-by-line to-do list of every switch statement to update. In dynamic Clojure, a missed branch or parenthesis only surfaced after a 25-second rebuild and browser test. Turn on strict typechecking and --warnings-as-errors everywhere.
Agents iterate in tight loops. Running 59 full interactive LiveView tests in 0.4 seconds or 41 Gleam tests in 0.3 seconds meant the agent caught subtle bugs immediately. Needing a 25-second release build plus Playwright waits made every mistake 10× more expensive.
Law 04 · Boring Beats Clever
Tooling stability trumps paradigm elegance
Electric Clojure v3 has arguably the coolest technical vision in this lineup, yet took more than twice as long as Phoenix. Why? Alpha API drift, an interactive dev-build license prompt, and unusual concurrent macro semantics. Give agents stable, non-interactive CLIs with clear error messages.
Methodological Honesty & Caveats
Agent transition: Experiment 01 (01-lamdera) had its baseline built earlier with Codex (~29m, including initial Playwright/Chromium OS library setup on Ubuntu 26.04) before quota ran out; its evolution challenges (C1–C7) and all of Experiments 02–06 (both baseline and C1–C7) were built sequentially by Antigravity in fresh isolated subagent sessions.
Gleam C6 timing note: Raw wall time for Gleam’s C6 was 39.1m because a bare wait command in the agent’s bash HTTP-storm harness accidentally waited ~31 minutes on the background server PID; active coding/testing time (~8.0m) is plotted in the charts above.
Local-only scope: Lamdera’s hosted cloud lamdera check (production Evergreen deployment) was not connected in this offline lab VM; instead, schema migrations were verified via compiled pure Migrations.elm functions and unit tests. All C5 demo account pickers are explicitly labeled as local-only demonstrations, never production authentication.