Tuesday 12 August 2003

Programming and the Law

No, this isn't about the latest silliness of the RIAA, or other people trying deperately to defend an obsolete business model in the courts. In fact, it's nothing to do with Courts as such - it's to do with legislation.

In my Brilliant <word_definition value = "to go downhill without control">Career</word_definition>, I've seen and done a lot of things. I've worked on systems for Printers, Small Businesses, in Veterans' Healthcare, Better Ways to Kill People, Spaceflight Avionics and Legal publishing. As a Systems Analyst, I've had to absorb the basics of all these "Problem Domains". I'm not a Doctor - but know about Ankylosing Spondylitis and Rickettsia Rickettsii from perusing data on Veterans Health. I'm not a Lawyer - but unlike most Lawyers, I've had to read every single reported case in every Supreme Court in every State of Australia from 1996 to 2000. And a lot of the legislation enacted over that period too.

Which leads me to a post from Samizdata.net.
Don't just sit there waiting for disaster to strike, says the lawyer. Think about it beforehand. Take precautions beforehand, with the magic of paper, that can clarify, now, what needs to be done, now, thereby preventing catastrophe in the future. So what if most people don't read it? The people directly instructed to behave themselves better, in such a way that catastrophe is averted, they'll read it. That's sufficient.
As you can see, this involves going beyond merely foreseeing disaster, to actually preventing it.
But isn't that what you would do if you spent your whole life imagining future catastrophes and trying to fix it so that if catastrophe did strike your clients would at least keep their skins in one piece? Wouldn't you, if you got a job where you were now expected to look at the bigger picture, then ask: well, can't we contrive more and better paper that would actually prevent these disasters?
So the laws and the regulations pile up, and the people agitating for them and writing them and voting for them all truly believe that they are doing us all a favour. That's what makes it all so dangerous. Bad people are relatively easy to stop. It's the good people you have to really look out for, if only because they are so much more numerous, and so much more persuasive.
...and much more besides. Go read the whole thing.

But what's really interesting is some of the comments;
I wonder are lawyers any good at programming?
Because thats exactly what "us" programmers do (predict mistakes and error paths).

<sarcasm>Of course computer code has got shorter over the years and less complex, so you can see we have been much more successful.</sarcasm>

Posted by: Rob Read on August 11, 2003 05:51 PM
(I inserted the "sarcasm" tags, as someone took him literally). Anyway, he's absolutely right. That's what "us programmers" do, to a great extent. And when you're dealing with Safety-Critical systems - things like avionics, where people's lives depend on the system - then it's 99% of your job. But the similarities don't stop there.
The code metaphor for law seems to work pretty well for me. From my experience (and that of others), as a body of code evolves over time, it becomes inflexible and spaghetti. Often, this is the result of fixing a specific problem in a specific case. Every so often, one or more pieces (often in tandem) needs to be ripped up and re-coded. Legal codes are huge bodies of code on which very little garbage collection has been performed.

Posted by: Dishman on August 11, 2003 11:21 PM
Exactly. What is a Law but a program?
IF you do this THEN you get thus-and-such a penalty. END IF

In fact, I was constantly struck by the extreme similarities between computer programming and the legislation my program was helping to publish. In programming, you have problems of "configuration management", that is, what's the latest-and-greatest code that works as opposed to what's still "under construction". And when do you publish rev 3.45, and what problems does it fix, and what problems are planned to be fixed in rev 3.46.

Legislation has exactly the same structure. Most legislation merely amends previous legislation, and comes into effect on a certain date. Before that date, the law says one thing, then magically, it says another. What was legal becomes illegal; what was illegal becomes legal. It's worse than that when you have the possibility of retrospective Legislation - that is, the question "Is this action legal" depends upon not just the date the action happened, but also when the question was asked. And sometimes the new law is defined to come into effect "2 weeks before the XYZ act comes into effect", so until that happens, you can't know what the law is. Or was. But I digress.

Australian Taxation legislation is so horrendously complex that I doubt that anyone understands it fully, and it must by its very nature be full of contradictions and inconsistencies. It's constantly being amended and fiddled with, so in order to know what taxes you should have paid 3 years ago, you sometimes have to wade through literally dozens of amendments.

Now Computer Programmers have managed, by making use of a formal set of symbols called a "Computer Language", with its own grammar, syntax and semantics, to ease their task. There are lots of languages, some highly Cryptic ( APL), some that are almost as bad to the uninitiated (C), yet others that flow like English ( Ada).

Warning!Don't follow the links in this paragraph if you're not a Computer Maven.
Some of these languages - such as the SPARK subset of Ada-83 and the RAVENSCAR subset of Ada-95 are "formally provable". You can always determine how the code will behave. In fact, with developments in xtUML you can actually "execute" the design model of the system.

But there is no "LawLan", no special, formally provable language for writing legislation. There's no way of writing a "Law Program" that you can execute under a variety of circumstances ("system tests") and see what it does. So we get unintended consequences, the Courts make rulings giving results that Parliament never intended. But sometimes they have to, because the Law is Inhuman - it's a Juggernaut that can crush the powerless and innocent unless tempered by some common Humanity and uncommon sense.

The Lawyer-cum-Information-Technologist who invents such a provable, verifiable law-language system - (and the person who manages to cajole the writers of Legislation into using it, and the Voting public to accept it) will be a candidate for sainthood, and will in all probability be martyred. But it's something we're going to need sooner or later.

No comments: