“Code is law” misconstrued as Legal Formalism

Mon 28 April 2025

An LLM was used in the composition of this essay, but the thoughts are my own.

Introduction

In my last post, I showed how common law principles apply to emerging technologies. I’ve since realised that the real driver isn’t common law itself but legal realism.

Legal realism holds that judges don’t merely execute statutes like code; they weigh social interests, practical consequences, and policy goals. In practice, law is a human endeavour, shaped by far more than formal rules.

Below, I’ll trace the origins of “code is law,” contrast legal formalism with legal realism, and explain why the blackhat’s claim — “if the code allows it, it’s legal” — distorts Lessig’s insight and courts’ actual practice.

A false interpretation

Lawrence Lessig famously observed that “code is law”, by which he meant that software architectures regulate behaviour just as statutes do. Lessig’s insight was descriptive, not celebratory: he warned that unaccountable code could wield the power of law without democratic oversight.

Yet you’ll hear blackhats invoke “code is law” as a defence after siphoning millions in crypto. This isn’t Lessig’s perspective at all, but rather a form of legal formalism: the idea that rules (or code) are self-contained, unambiguous, and must be “executed” without regard to context or outcome. In legal formalism:

Applied to smart contracts, formalism says: if the bytecode transfers funds, it must be legal. But of course, formalism ignores the messy realities judges confront: fraud, unfairness, public policy and the very human harms that flow from a blind insistence on “just the code.”

Enter legal realism, which extends and enhances legal formalism. In legal realism:

Realism doesn’t discard rules. It just recognises that rules alone sometimes yield harsh or absurd outcomes. Instead, it embraces judicial discretion as a feature, not a bug. Under realism, a judge faced with a billion-dollar exploit will look beyond the literal code to ask: What harm was done? What public policies are at stake? What would justice require?

In other words, legal realism elevates the role of judges to those who must interpret, adapt, and sometimes override formal rules to achieve fair and workable outcomes.

If you take “code is law” to mean “whatever the code does is legal” you’ve not only perverted Lessig’s insight, you’ve also misunderstood how legal systems actually function. Across both common-law and civil-law jurisdictions, judges retain the power to reach beyond a literal reading of statutes or code:

That’s legal realism in action. It would be hard to find a court today that would permit a multi-million-dollar theft simply because “the code said so.”

Four Quadrants: formalism vs. realism, common law vs. civil law

It’s important to note that common law vs. civil law and formalism vs. realism are orthogonal distinctions.

Common Law Civil Law
Formalism Rigid stare decisis Text-bound (legal) code execution
Realism Equitable discretion Statutory interpretation

Legal realism shows up differently in each system. In common law, judges use fairness and balancing tests to soften hard precedents. In civil law, they look at things such as the purpose of the law, good faith, and policy goals to fill gaps in the code.

Conclusion

In a future post I’ll put forward a fairly radical view: not only are “rules only” systems impractical but they can’t work, even in principle, once they push up against the messiness of reality. But for now, the lesson is clear: technology may execute code, but real-world accountability resides in courts guided by legal realism. Judges will look beyond virtual machines and bytecode to deliver justice.

So when you hear “code is law”, remember: that slogan only holds if you believe law is nothing more than mechanical rule-execution. In reality, law is a human enterprise and legal realism is the lens through which that enterprise must be understood.