SamBourque.com

How Law and Programming are Related

Published on March 12, 2025

How Law and Programming are Related

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.

Frequently Asked Questions

How are law and programming similar?

Law and programming are similar in that both provide structured guidelines that dictate behaviors and outcomes. Both fields use terms such as "execution," "processing," "statements," and "conditions" to describe their frameworks.

What is the role of precision in programming compared to law?

Precision in programming is crucial because it requires exact and explicit definitions, making the software generally unambiguous. In contrast, law is less precise as it involves interpretation and adaptation to accommodate human complexities.

How does mathematics relate to both law and programming?

Mathematics provides foundational concepts for programming with terms like "constant," "variable," and "function." While law uses mathematical concepts, its primary concerns are human-focused, whereas programming relies heavily on mathematical precision and logic.

Why can't law be as precise as programming?

Law can't be as precise as programming because it deals with human complexities that require flexibility and interpretation. Strict determinism in law could undermine justice, fairness, and compassion, which are essential to society.