Financial software sits at the center of modern economic infrastructure, yet the programming languages used to build it provide no formal guarantees about the semantic correctness of financial operations. Double-entry bookkeeping’s duality constraint, the rule that every economic event must produce balanced inflows and outflows, is universally encoded at the application layer, where it can be omitted, miscoded, or deliberately bypassed. No existing compiled programming language includes a type rule for accounting duality. This paper presents Equis, a compiled, self-hosting systems language that elevates the Resource–Event–Agent (REA) model to first-class syntactic constructs and enforces accounting duality as a static, compile-time invariant. The compiler rejects any event declaration whose flow block is not balanced before emitting a single instruction of LLVM IR. Equis uses fixed-point 64-bit integer arithmetic scaled by 106 throughout, eliminating IEEE 754 accumulation error from financial code paths entirely. Memory management relies on automatic reference counting with a resource-state borrow checker, giving deterministic, GC-pause-free behavior in long-running settlement services. The compiler is self-hosted, bootstrapped from ANSI C, and verified via Diverse Double Compilation to address Thompson’s trusting-trust problem. Contributions include the formal duality typing rule and its soundness proof, the full REA primitive syntax integrated into a systems language, role-based access control enforced statically at the agent-type level, an append-only ledger primitive with compensating-transaction semantics, and a 20-module standard library covering collections, ledger management, accounting, compliance, database access, HTTP, channels, and fibers. Equis is, to the author’s knowledge, the first compiled general-purpose language to embed REA semantics in its type system. Compile-time duality enforcement eliminates an entire class of financial logic errors with zero runtime overhead.
M Lintang Maulana Zulfan (Mon,) studied this question.