Friday, 26 August 2016

Let's start this by restating something which I've said often before, which has been for the past year the 'pinned tweet' on my Twitter profile.

The preservation, by the privileged, of their privilege cannot be a human right.

A group calling themselves Demos Scotland have proposed a draft constitution for a Republic of Scotland. As a convinced republican who believes that the independence of Scotland is in the interests not only of the people of Scotland but of the wider world, I am of course interested.

Now of course it's possible that Dr Mark McNaught, who posted this draft and presumably had a considerable hand in writing it, deliberately put in bombshells in order to spark debate. I don't think so, because, to me, most of the draft constitution reads very well; it's a sensible, if not a poetic or inspiring, document. But if he did he is to be congratulated, because I tripped over an epic one.

Consider article II.B.7:

[All citizens and residents of Scotland, regardless of their status, shall have] the right to hold private property, and to the peaceful enjoyment of his or her property.

Seems sensible, doesn't it, on the face of it? No-one wants strangers barging into their house in the dead of night and throwing them out into the street. No-one wants strangers arbitrarily seizing their phone or their laptop or their bicycle. Obviously everyone should have the right to keep their stuff, the right to enjoy their stuff in peace...

Oh, wait.

Wait a minute.

Wait a cotton picking minute.

This is Scotland we're talking about. Scotland in which just 432 citizens, residents and, in fact, primarily non-residents, own more than half of all the privately owned land, and similar proportions of other asset classes. So we're going to take that extraordinarily skewed distribution of wealth and we're going to enshrine in the constitution for all time?

I don't think so. I so do not think so. That is exactly how you start the bloodiest revolutions.

The right, in Scotland, to hold property cannot be unabridged. On the contrary it must be abridged by ideas about equity and justice.

There's a reasonable case to be made for a meritocracy: for a society in which everyone starts out with a more or less equal inheritance, and each person keeps all (or a high proportion of) the wealth they individually generate, through creativity or hard work, in their lifetime.

But the ability to acquire wealth is at least largely a matter of pure blind luck. A purely meritocratic society is not a generous place. It's not a good place to be ill, to be disabled, to have a random accident. A purely meritocratic society does not meet my conditions for a good society; I doubt it meets yours.

There's a reasonable case to be made for a communist society, in which private wealth, in so far as it exists at all, is distributed according to individual need - so someone badly disabled and not very productive would receive a slightly larger share than someone fit, creative and productive. As Marx expressed it, 'from each according to his ability, to each according to his needs'.

But many people will feel that a communist society does not provide enough incentive for people to achieve. To an extent, I feel that myself; when I finish writing this I'm off to buy myself a new bicycle, as a reward to myself for having worked hard and produced useful stuff. We are, at the very least, socialised to believe that good work should be materially rewarded.

However, I am going to assert that the good society lies somewhere between those two positions. The good society is not one in which the lottery of birth determines whether you have a life of ease or of hunger.

Looking at Scotland today, J K Rowling is hugely wealthy because work she has done in her own lifetime has given great pleasure to hundreds of millions of people. Richard Walter John Montagu Douglas Scott is hugely wealthy because he is the eldest male child of a long line of more or less rapacious mercenaries and thieves.

Of course, Rowling has also been lucky; across Scotland, across the world, other people were writing childrens' stories at more or less the same time. I'm an admirer of her work: it rattles along with pace and wit. But it isn't, qualitatively, vastly better than the work of many other contemporary writers. It's good; but also, she was lucky. She caught the zeitgeist and rode it.

A just society, I think (and I'm sure J K Rowling would agree), shares some proportion of that wealth around. To the writers who, for one reason or another, never caught the zeitgeist; to those who, for reasons of health or ability or luck, were never able to write at all.

But there is an element of merit in Rowling's wealth. She sat down and grafted. I know well just how much work there is in writing a novel, and particularly how much work there is in finishing one. There's no element of merit in Scott's wealth. He has done nothing significant to contribute to it, and very little at all to contribute to the well-being of the communities who have provided it.

There is, and must be, some moral distinction between these two types of wealth. I can see a good argument for J K Rowling being guaranteed a right to the peaceful enjoyment of at least some of her property. She has, one can reasonably argue, earned it. I can see no argument whatever that Scott should be guaranteed such a right. He is not a meritorious individual; on the evidence, somewhat the opposite.

So I'd like to propose an amendment to Demos Scotland's draft constitution.

II.B.7: delete all and substitute:

The right to hold a reasonable and limited amount of private property, and, within that reasonable limit, to the peaceful enjoyment of that property. Nothing in this clause shall invalidate any tax, duty or custom levied in accordance with the CSL, or an environmental regulation imposed on the development or use of land or natural resources. Nothing in this clause guarantees the right to pass property to a successor, nor to inherit property from a predecessor.

That last bit?

We all want to inherit from our parents. My father's copy of Heimskringla, my mother's rocking chair, my great grandfather's clock, the santa-claus hat I put on my little sister's gravestone each Christmas, are all precious to me. They are precious partly because they have been part of my life since early childhood, and partly because they bind important memories of people I've lost. To pass down small objects laden with memory and association from generation to generation seems undoubtedly a good thing.

But there's a line to be drawn somewhere between passing down these sentimental objects, and passing down items which make a fundamental difference to people's life chances. Is my life materially better because I have a copy of an old Icelandic book? Probably not. Is my life materially better because I grew up in a household where there were many books of early European thought and literature? Well, actually, probably it is. Would my life be materially better if I had inherited, for example, not an old and dusty book but the Madonna of the Yarn-winder?

Well, actually, yes it would. Dramatically better. And that is the point. We cannot have a good society and inherited wealth, because inherited wealth locks in inequity and privilege across generations. Even if you view earned wealth as a good thing, unearned wealth - inherited wealth - cannot be.

The right to property and most particularly to inheritance, in a good society, cannot be unconstrained.

Sunday, 14 August 2016

Writing software is about solving problems, about finding elegant ways to solve problems. But it isn't and shouldn't be about finding elegant ways to solve the problems caused by the shoddy workmanship and poor technical design of platform you're working on. If the platform you're working on is shoddy, don't work on it.

Jave inherits syntax from C, which in turn inherits it from BCPL, which inherits it from Algol. It inherits the idea of a virtual machine from BCPL's CINT Code Interpreter. It is, then, an imperative language, one step up from a macro-assembler. There's no mathematical formalism underlying its design.

There's a sort-of object-oriented layer bolted on top of the Algol-like language even in the earliest version of Java, but it's done without conviction. Primitive data items are not objects; there's no orthogonality. And there's no multiple inheritance, either, so it needs to be very clumsily simulated with interfaces. On the very small, memory-limited devices for which Java was designed, these were reasonable choices. But we now very rarely use Java in such constrained environments today.

The orthogonality problem was sort-of fixed in Java 5, with 'boxing' of primitives - if you referred to a primitive as if it were an object, the compiler would magically transform it into an object. But it's a hack.

And Java continues to be extended by hacks. Java 8, for example, hacked on functional programming, because functional programming is a fashion of today. But once again it's 'sort-of' functional programming, just as Java 1 was 'sort-of' object oriented.

Functional programming is in fashion today because we've reached the physical limits of Moore's law: individual processor cores are no longer getting faster. To increase performance, we need to share processing over more and more processors: to share the load. That's simple if the data being acted on by the process on one processor cannot be changed by a process running on a different processor, and so functional languages with closures and immutable data make programming for parallel architectures trivial.

But Java data is inherently mutable: that's the nature of object orientation. The state of an object is altered by setting its instance variables. Java also doesn't have first-class closures. So Java's 'functional programming' hack doesn't do what it implies on the tin: it doesn't make programming for parallel architectures trivial. On the contrary, it introduces more opportunities for subtle and intermittent bugs.

C# is, in origin, an even worse story than Java. Java was designed to do something - to be used to create embedded programs for small appliances. C# is just a fit of pique, because a judge wouldn't let Microsoft release a non-standard Java and call it Java. So C# is a language like Java and inheriting all Java's faults, but deliberately incompatible with Java. And as each new feature has been bolted onto the side of either Java or C#, the other has slavishly (but subtly incompatibly) copied.

Programming languages don't have to be like this. Structured Query Language is soundly based in relational algebra; Prolog is based on first order predicate calculus. But the only computer language anyone actually needs to know is a straightforward implementation of the mathematical basis of computation itself: the lambda calculus.

Yes, I know all computer systems of any significant size contain elements which seemed like a good idea at the time and which later turned out not to be. Interlisp, Portable Standard Lisp and Common Lisp are all examples of LISP-2 - they have separate value and function pointers on every symbol. Interlisp and Portable Standard Lisp both also have subtly different symbol binding mechanisms between interpreted and compiled code, which means that the scope of symbols is different leading to semantic difference - which was an uncommon but horrible pitfall when your code worked when interpreted but broke when compiled.

Interlisp had an awkward inorthogonality between older functions which have abbreviated names in ALL UPPER CASE and newer ones which have LongerNamesInCamelCase. Oh, and there was the curious CLISP feature which you could either see as magical or a well of despair, depending on how you used it (I didn't).

Finally, in the Medley release, Interlisp had Common Lisp bodged onto the side. Common Lisp is a bit of a mess anyway, but the attempt to make one system interoperate functions written in two different syntaxes must have made for interesting debugging. But I had moved onto Prolog before Medley was released, so I never really had to deal with that.

In most early Lisps, too, data wasn't really immutable. The functions rplaca and rplacd, which allowed the overwriting of pointers in data structures, were Lisp's dirty little secret. These 'destructive' functions made data mutable. But even back in the 1980s, when parallelism wasn't yet a significant issue, we knew that these functions were inelegant and shouldn't be used.

Of course, Clojure too has its faults. It is partially crippled by the JVM's limited, fixed size stack (back to that notional 32 bit minimal-memory set-top box Java was designed for); but while for many functions I believe that the recursive expression is both the most expressive and most natural, if you make idiomatic use of Clojure's lazy sequences the use of deeply recursive algorithms can be avoided.

There have been some bizarre decisions in Clojure's language design:

the default arithmetic operators do not gracefully switch to bignums on arithmetic overflow (although there are alternative operators which sensibly do, if you know about them);

nil is not the empty list (both (nil? '()) and (empty? nil) return false) and is also not false ((false? nil) returns false); also, bizarrely, the car of the empty list is nil ((first '()) returns nil) but the cdr is the empty list ((rest '()) returns ());

the decision to remove a layer of parentheses from cond and case means that pretty-printing does not give a rational code layout (and also makes translation of code from other Lisps that bit harder);

the decision to notate arg-lists and let binding lists as vectors is also bizarre and again introduces needless inorthogonality (yes, I know that as compiled for the JVM they're implemented as vectors, but that's an implementation detail)...

And so on. There is no perfect computer language.

But anyone who has looked at a fern-moss, or a frond of bracken, or a waterfall, or a birch tree, or a cloud, or a prawn, or the development of a human embryo, has to acknowledge that if God does not write Lisp, God writes some language so similar to Lisp as to make no difference. The physical world is built in all its aspects and at all scales of simple functions recursively applied. It physically hurts me to work on systems whose underlying architecture is a bag of hacks kluged together.