January 27, 2026
SQL on a treadmill
Arrows to Arrows, Categories to Queries
A quirky language turns big math into a giant database loop—fans cheer, skeptics groan
TLDR: A playful new language compiles programs into one massive database query that literally loops to 100. Commenters split between theory skeptics warning “arrows” are the wrong tool and veterans suggesting fixes like CTE unrolling—spotlighting the clash between clever experiments and real‑world SQL pain.
A bored dev built “catlang,” a tiny language that turns mathy ideas into one giant database query—and yes, it literally loops its way to 100. The demo compiles into a single SELECT in Postgres, and if you remove the final limit, you can watch every step like a treadmill for your data. Absurd? Ambitious? The comments say: both.
The drama split fast. One camp rolled its eyes at the math, arguing that “arrows” (a programming pattern) are the wrong tool because you can’t just drop normal functions into that world—cue sighs that this would “make arrows actually usable.” Meanwhile, battle-scarred query veterans nodded grimly: SQL (the language for databases) is a rough target, but hey, there are tricks—like unrolling nested parts into long chains of CTEs (named subqueries) to keep the beast tame.
Between the theory gripes and practical hacks, the vibe was equal parts academic roast and shop-floor therapy. Some readers joked about making Postgres do cardio—“watch it jog to 100”—while others admired the audacity of turning category theory into industrial-strength query spaghetti. Whether you see it as a beautiful stunt or a cursed marvel, the community’s united on one thing: this is chaotic, clever fun at database speed.
Key Points
- •The author built “catlang,” a programming language that compiles into a single SQL SELECT statement.
- •An example function uses arrow-like constructs and a loop to return 100 by iterative incrementing.
- •The source code desugars into a categorical intermediate language with simple algebraic semantics.
- •The IL makes it straightforward to target nontraditional backends, demonstrated by SQL generation.
- •The generated SQL runs in PostgreSQL 17, and modifying ORDER BY shows each iteration step; optimizations were noted but not implemented.