Monday, December 26, 2005

Law as Code

Larry Lessig broke through to celebrity with his book Code and Other Laws of Cyberspace. He argues that the writers of software code create frames for behavior that can be as coercive as the law. I’ve started wondering about the reverse: treating laws as if they were software.

Our intuitions are grounded in how our brains use our bodies to interact with the physical world. Software confounds those intuitions because it’s doubly inexhaustible: it’s made up of ideas which can’t be “used up”, and the resulting product is itself perfectly copiable infinitely many times. Both the input and the output of manufacturing software is non-rivalrous, to use the economic jargon.

As we build a knowledge economy, we are surrounding ourselves with abstractions for which our body-based reasoning is ill-prepared. Examples beyond software include quantum mechanics, persistent exponential growth (eg Moore’s Law for silicon chips) and products built on pure probability (eg futures markets, and lotteries in general). Not all of this is novel, though. Laws, lotteries and logic have been around for millennia. However, people at large have not had to worry about their weirdness because they have only been parochial concerns to date. The pervasiveness of software can open our eyes – especially if we’re geeks and not wonks – to some of the curious properties of law.

One can think of the legal code as the operating system for a country. If the laws are the operating system, then contracts are the applications. There are many more contract lawyers that lobbyists, just as there are many more applications than operating systems.

The amount of code in a software program can be measured by counting the number of lines of source code, that is, the number of lines of human-readable instructions. Contemporary operating systems contain tens of millions of lines of code (Wikipedia cites line counts for some common operating systems).

I was surprised when I totaled up the number of lines in the US Code, the compendium of all the (federal) laws of the United States: about 5 million lines (spreadsheet). That’s about the same size as Windows NT or the Linux 2.6.0 kernel, at 4 million and 6 million lines of source code, respectively.

The “core development team” for the US Code is rather smaller than that for Windows or Linux, which are both said to be in the region of 8,000 people. The Washington DC legislature consists of 50 senators, 400-odd members of the House, and their legislative staff. If we assume a member to staff ratio of 1:3, that’s a team of 1,800 “developers”. Of course, one can’t forget the lobbyists, many of whom are lawyers who do the actual legislative drafting. Roberta Baskin, Executive Director of The Center for Public Integrity estimates that the federal lobbying industry employs about 14,000 people to influence the decisions of Congress, the White House, and officials at more than 200 federal agencies. Not all 14,000 are working on the US Code; many are working on agency regulations, which geeks might want to think of as the “middleware” of the legislative machine. (Note that I’ve ignored state law and local regulations in this approximation; it shouldn’t change the answer by more than about a factor of 2.) In all, the number of people writing the operating system for the United States is approximately the same size as the teams working on PC operating systems.

The analogy offers endless opportunities for harmless fun and mischievous comparisons.

Developers and lawyers quite similar: both write code, both worry about misplaced punctuation marks that could ruin everything, and both spend a lot of time on “edge cases”. Neither has ever seen a piece of code that they couldn’t do better, and both spend more time maintaining and tweaking legacy code than writing new stuff. However, it may take a little while for the maintenance of the US Code to be off-shored to India…

Legislation is infested with inconsistency; software tools that track links between code modules could help find discrepancies. S. remembers that her family was perplexed by what to do about an old tree in their garden. One regulation insisted that they cut it down, because it was old and rotten, and another insisted that it be protected, because it was just plain old. (They cut it down.) On the other hand, while tools can find buffer overflows in software, one needs the CBO to find budget overflows since legislation is code which is designed to run in the future, and have its worst side-effects when its drafters have happily retired to working as lobbyists.

One could see most of the activity in national and state capitals as the frantic “patching” of unintended side-effects in legal code. Tax lawyers seeking loopholes and hackers looking for trapdoors have similar goals – making the code do something it was not designed for. Unfortunately, it takes rather longer to patch the legal code than it does to issue a security update.

The judicial system is the “execution environment” for the code the makes up the code for a country. (In country as enamored of the death penalty as the United States, that computing term is more accurate than one might wish.) The courts figure out what the legal code actually does in practice. The function of the courts highlights a weakness in my analogy: laws are written in ordinary language with all its delightful vagueness, whereas computer code is written in mathematical symbols dressed up to look like language. In software, ambiguity is a bug; in law, it’s often a feature.