As 2026 unfolds, software engineering continues to collide with esoteric theoretical mathematics in unexpected ways. A developer recently released catlang, a custom programming language that compiles directly into one giant SELECT statement. When executed in Postgres, this single massive query produces the entire output of the original program.
Created during a period of time off, catlang was built to test out language features using an intermediary language made of abstract category theory. Rather than introducing a new query language, the project functions as a programming language whose compiler spits out a single query. The creator noted that the work also yielded a working arrow desugarer as part of the mix, processing structures that resemble large proc blocks.
From Abstract Theory to Recursive SQL
The compilation process takes high-level syntax—such as a function designed to return 100 regardless of its input using the equivalent of a while loop—and desugars it into an intermediary representation. Each remaining symbol in this categorical representation carries specific algebraic semantics, such as piping the result of one operation into another. By establishing transformations from this categorical intermediate language, compiling to unusual targets like SQL becomes possible.
Running the resulting code generates extensive Postgres statements.
Catlang Compiles Down to One Giant SELECT Statement
- Catlang compiles down to one giant SELECT statement for execution in Postgres.
- The language uses an intermediary layer built on abstract category theory nonsense with simple algebraic semantics.
The obtuseness of the language design was not implemented strictly as a feature, but rather to explore conceptually simple operations that could easily be translated into category-theoretical components. Further details on the project and its mechanics are documented in Arrows to arrows, categories to queries (2025).