How Law and Programming are Related
Published on March 12, 2025

Code is Law for Machines
At a fundamental level, programming and law share deep conceptual similarities. In fact, the term "code" itself originates from legal language, historically referring to codified statutes or regulations. Code—in programming—functions similarly for machines as law does for humans: it provides clear, structured guidelines that dictate behaviors, responses, and outcomes.
Shared Vocabulary, Shared Concepts
The overlap between law and programming is further highlighted by their shared vocabulary. Words like "execution," "processing," "statements," "conditions," and "terms" are central to both fields. While their precise meanings differ, their fundamental roles align remarkably:
- Execution: In law, this can mean carrying out or enforcing a judgment; in programming, it's running instructions on a machine.
- Processing: Legal systems process claims, documents, or evidence; software processes data inputs.
- Statements and Conditions: Both fields rely heavily on conditional logic—laws have conditions and clauses; programs rely on conditional statements and logical branching.
- Terms: Contracts specify terms (conditions and definitions), just as code defines terms (variables and constraints).
Mathematics as a Common Ancestor
Not all programming concepts share legal roots. Many programming terms derive instead from mathematics—words like "constant," "variable," or "function." These terms are not alien to law, but their meaning aligns more naturally with mathematics. Law may employ mathematical concepts (such as interest calculations, taxes, or penalties), but mathematics and logic are foundational to programming in a more intrinsic, structural way.
Precision versus Ambiguity
While law and programming share many parallels, they differ significantly in terms of precision. Programming demands exactness and explicit definition, making software code generally unambiguous and deterministic—apart from occasional bugs or unforeseen errors.
Law, however, is intrinsically human-focused. It reflects humanity's complexity and ambiguity, intentionally leaving room for interpretation, adaptation, and discretion. Human language, human relationships, and human behaviors rarely fit neatly into deterministic frameworks, making legal interpretation an inherently nuanced endeavor.
Programming as the Ideal of Precision
From this perspective, programming represents a kind of idealized version of law—a perfect system of rules, unambiguous and consistently enforced. Yet the aspiration for law isn't to mimic the exactness of code. Absolute determinism in legal contexts could undermine fairness, compassion, and justice—qualities that define our humanity and underpin our society.
Ultimately, while programming can inspire law by demonstrating clarity and structure, law must remain flexible enough to accommodate human diversity, complexity, and imperfection.