Friday, 20 March 2009

Not quite a chip off the old block

In 1936, Pierre-Jules Boulanger asked his engineers to design him a 'toute petite voiture', and they responded in style. They were French, and it showed. They designed a car with flair, with elan, with chic, and with a certain joi de vivre. They designed so well that their little car was still in production fifty-four years later, and won the hearts of millions of people across Europe and Africa. The Deux Chevaux was not only an enormously practical, reliable, adaptable and economical vehicle, it was also the world's most underrated sportscar - more fun to drive than anything else I have driven with the sole exception of a Lotus Elise. I loved mine. It was my favourite car ever.

Which is why the petite voiture which sits outside my house now is another Citroen: a C3 Pluriel, a car whose design pays conscious homage to the Tin Snail. Less characterful, perhaps, blander, the curves rounded off into something closer to a child's toy aesthetic, but echoing the high-arched roofline and the bulbous curving bonnet. And echoing the original in other ways, too - in it's folding canvas roof, in its claimed versatility.

I've lived with mine for nine months now, for ten thousand miles. I like it very much. But it has to be said that as a replacement for the Deux Chevaux, it fails.

Why?

Let's start with the roof, since it's such a significant part of what makes both cars outstanding. In the 2CV, there are four positions for the roof. The first is, obviously, closed. Release two latches - which can be done from the driver's seat, but ideally not when the car is in motion - and the front half of the roof folds back. With it back the aerodynamics are reasonable - there's no significant buffeting. To get to the next position, one must stop, get out, unclip the roof from the front frame, and roll it up manually. It then clips in a neat bundle above the rear window, leaving the car essentially roofless. Again, the aerodynamics are OK - there aren't any real problems with harmonics. To get the roof right back, one needs tools: four bolts, and the whole roof and boot lid can be removed. It doesn't normally leak, there's virtually nothing to break, and one can still buy a complete roof assembly for £150. In the words of another French engineer of the interwar years, 'c'est brutal, mais ca marche'.

Contrast the Pluriel. Superficially it's better. The roof has six positions, and all the first five can be selected electrically with the car in motion. The last involves stopping the car, opening the boot, and swinging the neatly folded roof and rear window assembly down under the boot floor. This is easy enough - it's nicely counterweighted and needs no strength. Furthermore, with the roof folded away, the side arches can be removed resulting in a completely open car - something I very much appreciate and which wasn't possible with the 2CV. Removing the side arches is a matter of undoing four latches and lifting them away from the car. With the arches removed, the car is remarkably neat. No tools are needed.

But. But.

With the roof opened to the second position there's quite intense buffeting above about 50 mph, and in the fourth position there's a harmonic that's so intense above that speed that I worry about the structural integrity of the roof. With the roof in the fifth position - neatly folded on the rear window - there's buffeting, but it isn't extreme and the car can be comfortably driven in that state. And with the roof in its sixth position, below the boot floor, there's no more buffeting than you'd expect in any open car. But rather than six usable roof positions you really have only four, the same number as the Deux Chevaux.

Of course, you can still select between three of these when on the move. But the electric mechanisms which make that possible, and which control the latching and unlatching of the rear window, are clear weak points. If the electrics fail, you cannot close the roof, whatever the weather. There is no manual override. What in the 2CV was a simple sheet of waterproofed canvas has grown in the Pluriel into a minor miracle of engineering; and with that complexity has come cost. Where a new roof for a 2CV costs £150, a new roof for a Pluriel costs £2400.

And, it leaks. I'm not really complaining, I'd read the reviews and knew leaks were a feature of the design before I bought it. Mine leaks into the boot - things left there over a rainy night come out extremely damp. It's not a big problem, and I think the virtues of the design outweigh it; but I can't help thinking that the pivoting rear window contributes to this. Furthermore, the mechanism for swinging the rear window down takes up quite a lot of room in what is already a small car.

Which brings us to the next point. The Tin Snail was a genuine four seater car (it even had four doors). It could seat four adults without their being unduly cramped. Boulanger was a very tall man, and insisted on being able to sit comfortably in the car. The Pluriel claims to be a four seater, but in truth it's a four seater only if the driver is a midget, or if the rear seat passengers have had both legs amputated above the knee. With me in the driving, there is 40mm between the back of the driving seat and the front of the back seat; and I'm a lot shorter than Boulanger.

There's another issue with those rear seats. They have reinforced, non-adjustable head restraints, which form part of the car's roll over protection. Both the 2CV and the Pluriel present themselves as adaptable, utility cars. In the 2CV, the rear seat unclipped and could be removed easily leaving a large load floor. This would easily take a pair of race bikes with only the front wheels removed. The rear seats of the Pluriel don't remove; instead, they're meant to fold. But they're too big. When folded, the reinforced head restraint prevents the drivers seat being moved into a position that is comfortable for me to drive in. This means that only the passenger side rear seat can be folded flat if I'm to drive. It is still possible to fit one race bike in with both wheels off, but it's a squeeze.

Of course, like the 2CV before it, the Pluriel is designed with mountings for a roof rack - it's the only convertible currently for sale in Britain with mountings for a roof rack. So in theory one ought to be able to put the bikes on the roof... Except that my local Citroen dealer tells me the roofrack has been discontinued, and I haven't been able to locate one.

And then, of course, the Pluriel is much heavier, and consequently much less economical, than its ancestor. The 2CV weighed 560Kg, just over half a ton; with the benefits of modern advances in materials science, the Pluriel weighs 1158Kg. Of course, Citroen are not the only marque to fall into this trap; Issigonis' Mini weighed 617Kg against its modern successor's 1132Kg. A little of that extra weight is going into 'safety'; a little, more questionably, into 'comfort' and 'refinement'. But none of these cars major in refinement or comfort. The Citroens major in fun and adaptability, and the 2CV could legitimately add to that, 'economy'. The extra weight, sadly, means that the Pluriel cannot.

So what's my conclusion, after living with the Pluriel for nine months and ten thousand miles? Well, I like it very much; I find it hard to imagine another modern car that would suit me nearly as well. But if I could have brought a brand new 2CV instead, there would have been no competition. I do appreciate the removable side arches; they're (for me) a real improvement. The Pluriel is slightly more refined. The build quality does seem to be a bit better. But for the rest, it's much less engaging to drive, much less economical, and much, much less practical.

Monday, 16 February 2009

John Knox stirs in his grave

It would become illegal to view this picture in Scotland. 
OK, let's start at the beginning. My party - the Scottish National Party - has introduced legislation making it an actual crime for girls under sixteen to have sex, and is now proposing to make it a crime to have images of 'rape'. These two matters are not distinct, they're linked. And to talk about why they're linked I want to start by agreeing that, yes, there are public policy issues here.

Young people are vulnerable to older people. When very young, they're very vulnerable; we teach young people to view adults as authority figures. Most of the time this is a good thing. But it means that young people are vulnerable to sexual advances from older people, sexual advances which they might have rejected from someone who did not have perceived authority. And, young people inevitably have less experience of sexuality than their elders; they don't have an appropriate repertoire with which to respond, and this too makes them vulnerable. So young people do have to be protected, and it's right that, as a society, we have rules which prevent adults predating sexually on children.

Similarly, rape is a serious matter. Rape, even if not violent, can have a devastating psychological effect on the victim. Again, issues of authority and of power are involved in rape. It's obviously right that, as a society, we should have rules which protect people (mostly women) from being forced into unwanted sex by others (mostly men).

So I'm not arguing for rape or for paedophilia. I'm arguing for open debate, clear thinking, honest statement of problems and issues. I'm arguing for free speech, and for freedom of artistic expression. Because it is at least partly through artistic expression that society develops its norms, and passes them on to rising generations. When Charles Dickens was concerned about the condition of children in Victorian London, he wrote novels about it. When Robert Burns wanted to express his opposition to slavery, he wrote poems about it. The novels and poems reached a far wider audience and ultimately affected political change far more effectively than dry factual accounts.

I'm not arguing that paedophilia is acceptable, but why is there considered to be a crime committed when two fifteen-year olds make love? Are they each supposed to be predating on one another? Are they each supposed to be predating on themselves? And does anyone - does anyone - believe that to have the police intervene in a relationship between two fifteen year olds is not going to be far more harmful to them than under-age sex ever is?

Yes, the state must provide young people with appropriate education, appropriate access to contraception and health-care and counselling. Yes, the state must protect young people from predatory adults. But criminalising the first tender development of sexuality? That is - literally - obscene.

And so we move onto the second issue. The government - my government - my party - proposes to make it illegal to possess images of
'Rape and other non-consensual penetrative sexual activity, whether violent or otherwise...'
Part of the legal fiction which gives rise to this sort of legislation is that somehow consent is simple, and that it's possible to tell from an image whether consent was given or not. But in practice, consent is not that simple. A person may consent to an act with a given partner, and not consent to the same act with the same partner a few days or hours or minutes later. The act is not different. One could not necessarily tell, looking at a photograph afterwards, which act was mutually consented to and which was not.

The need for sexuality, and the nexus between sexuality and aggression, is very deep in the human psyche, very close to the centre of who, and what, we are as people. We all have it, and it troubles many of us in one way or another. As playful creatures, many of us choose to explore these issues through play. Play in which there may be many layers of the granting or withholding of consent; games in which people may choose to consent to engage in forceful sex against their active protest.

And many people - perhaps, we don't know, very many people - find some degree of pain or fear enhances sexual pleasure. Consensual sexual activity can be extremely vigorous, can be extremely uncomfortable, and can involve implements designed and intended to cause pain. How many decent middle class homes in Scotland have a pair of handcuffs or a whip or flogger hidden at the back of a bedroom drawer? We don't know. I don't know and you don't know - because we're a sexually repressed nation. But the people who sell these things do a good trade, here in Scotland; I'd hazard a guess it's more than any of us would think.

This isn't to defend rape. It isn't to excuse rape. But rape is something that happens inside the head of the victim - consent is either given or withheld. Consent is not something a picture can show. Coercion does not need to involve violence; no matter how tender an image of sexuality, we cannot know by looking at it that one or both of the participants was not blackmailed into taking part. No matter how apparently violent an image of sexuality, we cannot know by looking at it that it has not been positively chosen and is not being actively enjoyed by all concerned.

There is a yet more serious issue beyond this. The present legislation is aimed at images; but will have a chilling effect on all art forms. If we cannot explore issues of sexuality, coercion, violence in narrative, in stories, in film, in other art, how are we to give our rising generations language in which to explore and understand what is appropriate and what is inappropriate? Repression does not stop things happening. People will continue to have sex. Some of that sex will continue be rough. But if we have outlawed discussion about what is, and what isn't, acceptable to us as a society, how are victims to know when it is appropriate to protest?

Wednesday, 1 October 2008

Sex, adolescents and the law

Adolescents have sex.

This impacts on their lives negatively in a number of ways - certainly under-age pregnancy is now a very serious matter for public policy concern and the spread of sexually transmitted diseases among the young is also worrying. It's obviously undesirable to have adults predating sexually on children. It's also highly undesirably that young people of either gender should be pressurised into sex before
they're emotionally ready.

But that's precisely the point.

Emotional readiness does not occur miraculously on your sixteenth (or, in Scandinavia,14th, or in the USA, 18th) birthday. It happens when it happens. I personally didn't have 'underage sex', but then I was a late developer - many people with whom I've discussed the matter did, and most of them think (as adults) that it was a good thing, the right thing for them.

Legislation - the criminalising of normal, innocent and tender sexual behaviour - is grotesquely wrong; a quite immoral step to take. Where two fifteen-year-olds have consenting sex in the context of a relationship however ephemeral, the limit of public policy concern should be, had they had appropriate education to help them make the decision, and did they have appropriate access to contraception. And if they did not, the failure - the 'crime' if you like - is not theirs but ours - society's - for not providing these things.

Personally I'd go further and argue that adolescent sexuality between partners not more than two years apart in age should not be criminalised. We do - and should - expect older people to be more responsible. But a relationship between a seventeen year old and a fifteen year old does not seem to me perverse, unnatural or worthy of criminalisation.

There are, of course, serious issues here around alcohol, consent, and peer pressure. Access to alcohol does seem to me a matter for public policy intervention and I fully support the Government's plans to raise the age at which it is legal to purchase alcohol. But peer pressure is not going to be resolved through legislation. No matter how draconian and intrusive we make the state, adolescents are still going to whisper among themselves about who's 'doing it', boast, exaggerate, or feel left out. Education can address this. Legislation can't.

I don't want ours to come to be seen as the killjoy party, or the party of the old against the young, the spiritual and political successors to the unlovely John Knox. Alcohol we must indeed deal with. But when you pile one thing on top of another, young people in Scotland are bound to come to the view that the SNP is hostile to them, and that is going to cost us votes. But, aside from that, we should not do this not because it is in our partisan interest not to do this, but because it would be immoral of us to do this.

This is not a matter for criminal law.

Saturday, 23 August 2008

Medals, counting and chauvinism

The BBC has a predictable story this morning about whether Scotland will have its own team at the London Olympics. Which is a silly season story, a slow-news-day-story, a non story. First of all, it is quite possible that by 2012 Scotland will be irrevocably on the road to independence. We should have had a referendum before then, but even if the unionist parties block it we will have both Holyrood and Westminster elections before then, and it is entirely possible under present circumstances that the SNP will gain an absolute majority of Scottish seats in both.

In any of those cases, of course there will be a separate Scottish team at the London olympics. On the other hand, if Scotland fails to choose independence, of course there won't. It's as simple as that.

But there's a deeper, nastier chauvinism behind the story. The British media - the BBC inter alia, although they may not be the worst offenders - have been making a big deal about 'Team GB' coming fourth in the 'medal table' as if that somehow reflected credit on the second most obese nation in the world, the nation of lard arsed couch potatoes whose nearest approach to athleticism is the five-metre waddle from the double yellow line to the pizza counter.

Scotland shouldn't have its own team, runs the argument, because if it did 'Team GB' might not come fourth in the table.

But look at that medal table, and what do you see? You see big, populous countries at the top. If you adjust it by population, suddenly 'Team GB' is not fourth but twenty second. Russia was not third but thirty-sixth. The United States were not second but forty-fourth. China was not first but sixty-sixth.

If there is credit due to nations for their athletes' success, it goes to Dutch Antilles and Jamaica, with far and away the highest ratio of medals to population. The best performers among the European nations were Slovenia, Norway, Estonia and Latvia - all smaller than Scotland. And Australia - about whose relative 'failure' the BBC has been crowing - did substantially better than 'Team GB', at sixth. But do nations deserve credit, and if so why? These athletes are extraordinary individuals, and their successes are individual successes.

Let's stop to consider where the credit lies for Scotland's performance. I don't yet know - because it's not in all cases obvious which athletes are 'Scottish' - how well Scotland performed. But our outstanding athlete was Chris Hoy. Where did he develop his talent? Meadowbank Velodrome. What is Scotland doing to celebrate? Demolishing it. To say 'yes, but we're also building one in Glasgow' is no excuse. That a city the size of Edinburgh has nowhere for young cyclists to race in safety is quite simply a scandal.

So what's this about racing - and training - in safety? Jason McIntyre should have been another of Scotland's athletes competing for medals in Beijing, but he couldn't make it - because 'Team GB' couldn't give him a safe environment to train, because Britain's casualness about driving standards casually killed him. And while the team were out in Beijing, Davy McCall, who represented Northern Ireland at the 1998 Commonwealth Games in Kuala Lumpur, was killed in exactly the same way. This is how Team GB supports our elite athletes: we kill them.

Our athletes have done extraordinary things. They deserve enormous credit. But they've by and large done extraordinary things in spite of, rather than because of, the support (or lack of it) we've given them. Politicians - of any party, even mine - who try to take credit for the achievements of Chris Hoy need also to take responsibility for the death of Jason McIntyre. Where are our next generation of elite cyclists going to come from, if we demolish the velodromes and treat the slaughter of cyclists by motorists as a peccadillo?

Yes, but how did Scotland do?

So, after the rant about how bad chauvinism is and how credit for the achievment rests with the individual rather than the nation, how did Scotland do? Well, one person won all our gold medals. Step forward Sir Chris - without you Scotland would have had a very thin haul. Without Meadowbank Velodrome, indeed, we wouldn't have had two thirds of our medals, because one of 'our' three silvers came from Ross Edgar. If Chris Hoy, rather than Jason McIntyre, had gone under the wheels of a careless motorist this spring, we'd have had no golds at all.

For the rest, Katherine Grainger brought us a rowing silver - but as part of a crew of four the rest of whom were not Scots. David Florence won a silver canoeing. And that's it; that's all, folks. Six medals, four in the velodrome, two on the water. Three gold, three silver. And, arguably, two which an independent Scotland would not have got, since one of Hoy's and Grainger's came in team events with non-Scots making up the bulk of the team.

So how does that compare? 'Team GB' scored 1 medal for every 1.3 million people - as against China's 1 medal for every 13 million people or Jamaica's one medal for every 250 thousand. Team GB scored one gold for every 3.21 million, as against China's one gold for every 26 million or Jamaica's one gold for every 450 thousand.

If you consider 'pure' Scottish medals only, leaving out Hoy's team sprint and Grainger's sculls, Scots athletes bring home one medal for every 1.28 million Scots - marginally better than Team GB - and one gold for every 2.55 million Scots, considerably better than Team GB. If you count all the Scottish athletes' medals, Scotland has one medal for every 850,000 people, and one gold for every 1.7 million.


Looking at medals score and bragging rights and all the chauvinist claptrap alone, Scotland has no reason not to fly our own flag at the next olympics. We do have the talent.

Sunday, 17 August 2008

It's not cricket!

Look, lets stop fooling ourselves. The London and Edinburgh velodromes have both been sold off to developers - the London one, supposedly, to help pay for the Olympics. We have Chris Hoy because when he was developing in the sport there was a velodrome in Scotland for him to learn the ropes. Now there isn't - so where is the next Chris Hoy coming from?

There's someone else from Scotland who should have been winning medals for us at this Olympics. Jason McIntyre should have been doing for us in the man's time trial what Emma Pooley did so brilliantly in the women's. But Jason couldn't be there - because some careless motorist killed him while he was out training this spring (and was fined a derisory five hundred pounds in punishment).

Cycling doesn't have too much spent on it. Cycling doesn't have nearly enough spent on it. Every medium sized town has an Olympic size swimming pool. Every city has a running track. And we have one - count them, one - indoor velodrome in the whole country. In no other of our elite sports do we turn promising young athletes out onto the roads to battle it out with speeding motorists too busy with their mobile phones to pay attention to where they're going.

And yet half of all Britain's gold medals this year have come from cycling. Half. As many as all other sports put together. And there are more to come - Victoria Pendleton, Mark Cavendish and Shanaze Reade haven't even started yet.

So no - it isn't cricket. It isn't dull and tedious and arcane. It's epic and explosive and tactical and colourful and glorious. And we're good at it. So for heaven's sake get behind our cyclists and support them. Because if you think this is good, you ain't seen nothing yet.

Saturday, 26 April 2008

The spread of knowledge in a large game world

part of the role of Dandelion, in The Witcher games,
is to provide the player with news
These days we have television, and news. But in a late bronze age world there are no broadcast media. News spreads by word of mouth. If non-player characters are to respond effectively to events in the world, knowledge has to spread.

How to model this?

Some non-player characters - doesn't need to be many - are news-spreaders. News-spreaders need to travel. They have to travel even when there are no player characters in the vicinity. But, they don't have to travel very often - once or twice every game day. When a news-spreader is in the immediate vicinity of another character, the pair may (with some degree of randomness) exchange news. There needs to be a hierarchy in the exchange of news, so that 'I-saw' events need to be more likely to be passed on than 'I-heard' events; there needs to be a counter which counts the number of times a knowledge item has been passed on, and also an age counter so that knowledge items are less likely to be passed on as they get older.

One obvious class of news-spreader is a merchant. Merchant agents can either shuttle mechanically between a fixed group of markets or else possibly respond intelligently to supply and demand. Provided that there is a mesh of merchant routes covering the markets of the game world, and that a useful subset of non-merchant characters are required to visit a market every few game days, this should give a reasonably realistic framework for news spreading.

What else? What things qualify as news items? I think at least the following:
  • Deaths of sentient characters, especially if violent
  • Commodity prices
  • Changes of rulers in cities
  • Marriages of sentient characters
  • Plot events, flagged as events by the game designer
Obviously, news is more valuable if the people involved are important or notorious: the significance of a story is probably the product of the significance of the people concerned.

So a news item becomes a tuple

(days-old nth-hand significance action (actors))

for example

(54 2 10 'killed '(fred joe))

meaning 'I spoke to a man who'd spoken to a man who said he saw notorious fred kill well-liked joe on 54 days ago'. Obviously, the non-player character must be able to construct a natural language sentence from the tuple when speaking within the hearing of a player character, but there's no need for a non-player character to produce a natural language sentence for another non-player character to parse; instead they can just exchange tuples.

But if we're exchanging knowledge between agents, then agents must have a means of representing knowledge. This knowledge is an association between subjects and sets of statement, such that when the agent learns the statement

(54 2 10 'killed '(fred joe))

it adds this statement (with the 2 incremented to 3) to the set of statements it knows about fred and also to the set of statements it knows about joe. It's possible that the receiving agent could then challenge for further statements about fred and/or joe, the automated equivalent of a 'who's joe?' question.

There could be feedback in this. Fred's and joe's significance scores could be incremented for each character to whom the statement is passed on, increasing the likeliness that fred, at least, would feature in more news stories in future. There needs also to be some means of managing how the non-player character's attitude to the subjects of the statement are affected. For example, If fred kills joe, and the character (say bill) receiving the news feels positively towards joe, then bill's attitude to fred should become sharply more hostile. If bill feels neutral about joe, then bill's attitude to fred should still become a bit more hostile, since killing people is on the whole a bad thing. But it bill feels very hostile towards joe, then bill's attitude to fred should become more friendly.

Obviously the rate of decay, and the degree of randomness, of the news-passing algorithm would need to be tuned, but this schema seems to me to describe a system with the following features:
  • Non-player characters can respond to questions about significant things which happen in the world - without it all having to be scripted
  • If you travel fast enough, you can keep ahead of your notoriety
  • Characters on major trade routes will know more about what is happening in the world than characters in backwaters
This seems to me a reasonably good model of news spread.

Scaling of the algorithm

Let's work around the idea that a 'game day' equates to about two hours of wall clock time. Let's work around the idea that there are of the order of fifty markets in the game world, and that for each market there are two or three merchants whose 'home base' it is.

Obviously non-player characters who are within the vicinity of a player character have to be 'awake', in order that the player can see them interacting with their world and can interact with them. Those characters have to be in working memory and have to be in the action polling loop in any case. So there's no extra cost to their gossiping away between each other - around the player there's a moving bubble of gossip, allowing each character the player interacts with to have a high probability of having some recent news.

But the merchants who aren't in the vicinity of a player don't have to be in working memory all the time. Each merchant simply requires to be 'woken up' - loaded into memory - once per game day, move a day's journey in one hop, and then, if arriving at an inn or at a market, wake and exchange news with one resident character - an innkeeper or a gossip. So the cost of this algorithm in a fifty-market game is at worst the cost of loading and unloading two non-player characters from memory every minute, and copying two or three statements from the knowledge set of one to the knowledge set of the other. If you're dynamically modifying significance scores, of course, you'd need to also load the characters about whom news was being passed on; but this still doesn't seem unduly onerous.

Obviously, if memory is not too constrained it may be possible to maintain all the merchants, all the innkeepers and all the characters currently being talked about in memory all the time, further reducing the cost.

Friday, 4 April 2008

Worlds and Flats

Of Compartmented Worlds

Playing The Witcher has got me thinking again about an algorithm for rendering a world which I first thought of twenty-five years ago. Then, it was a hack for dealing with the fact that the computers of the day didn't have much memory or horsepower. Now, it's a hack for dealing with the fact that - when considered against the complexity of a world - the computers of today still don't have enough memory and horsepower. Mind you, today I'm contemplating photorealistic scenes, whereas then simple line and wash would have been good enough, but...

The algorithm for rendering I'll call 'flats'. But before we get to discussing flats, lets discuss worlds.
The world of The Witcher (and other games based on the Aurora engine) is composed of areas. One area is loaded into memory at a time; when the player reaches an area boundary, the area is unloaded in toto, and the next area loaded, also in toto. The result is a noticeable interruption in game play. There's also, normally, a noticeable visual disjunction at the boundary; the new area uses a different 'tileset', which is to say, set of bits of scenery. When you look across a boundary, the scenery often appears different from what you find when you cross the boundary and arrive at the other side.

Finally, you can only cross boundaries at specific gateway points. For example, Chapter Four of The Witcher takes place in a continuous rural space composed of three main areas: the lakeside, the village, and the fields. Between the lakeside and the other two regions there's a wooded escarpment, which provides some logical justification for the fact that there are actually only two places you can actually cross it - from the lake shore, either up the road to the village or else through a series of glades to the fields. But between the village and the fields there's no such logic. There are a pair of gateposts, and you must cross between those gateposts - but the landscape appears continuous, with no visible barrier. It's an artifact of the game engine.

So, how to deal with this?

My interest, let's be frank, is in story telling; and the nature of story telling is moderately constrained plots. In computer mediated story telling the reader/player can and should be able to explore the plot in his own way, make his own choices, take his own path through the environment, encounter the elements of the plot as he encounters them on that path, and it's the job of the story teller to make that engaging whatever path the reader takes. But if the reader chooses to ignore your hints and wander out of the area you've populated with plot altogether, there's two things you can do. One is put up physical barriers which stop him (although the silly field fences in Chapter One of The Witcher do /not/ count, as it's obvious that Geralt could simply hurdle them; they are just another artifact.

Of Finite and Infinite Worlds

But an infinite world is not required for the sort of stories I'm interested in; the sort of stories I'm interested in take place in, at best, regions of infinite worlds. Just because I don't choose to use all of it, of course, is not a reason that a world should not be infinite.

There are plenty of fractal mathematical equations which map an infinite three dimensional surface with landscape like features. If such an equation gives you land heights, then altitude, steepness and orientation will give you soil type and vegetation cover. There is no need to store a whole world in order to be able to reproduce it exactly when the player follows the same route through it for a second time; it is sufficient to start with the same seed. So a world need not take up vast amounts of disk space for pre-mapped scenery; scenery need only be mapped as it comes in sight. This is fundamentally the trick used by Elite to pack a large, reproducible universe into less than 32K of RAM, and it still works today.

Of River Systems

However, there are reasons to prefer that a world be pre-mapped, at least at coarse grain. One example of why is river systems. It's trivial that we render a river at the bottom of a valley, but it isn't trivial to compute how wide and deep that river should be. To calculate that we have to explore the extent of the watershed upstream of any given point, and sum the rainfall on it, which in turn is a factor of exposure to prevailing airflow and the proximity of ocean to windward. It's computable, but it's much more efficient to compute it once and cache the results, especially since for any given river system it's a recursive function.

Furthermore, rivers cause erosion, changing the landscape through which they pass, cutting gorges on steep slopes (especially if soft), building up flood-plains in flatter areas downstream. Some fractals are naturally extremely landscape-like, but it seems to me - better mathematicians might prove me wrong - to realistically render river systems requires some degree of post processing, and post processing which would be expensive to do repeatedly in realtime.

Of Human Settlement

Human settlement is a separate issue. Many years ago I wrote a program which modelled the spread of human settlement over a landscape.

Human settlement is not random. Human settlement follows rules and patterns. Pioneers settle in places which have a sufficient spread of resources to meet their year round needs; they settle near to easy routes from their parent settlement. Pastoralists need grazing land and water; they spread up river systems, but avoid marshy areas. They settle where there is open grazing, but often close to a forest edge for access to timber. Second wave settlers prefer to settle close to existing settlers, for mutual protection and help. Cereal growers join these settlements where the depth of soil is optimal for crops. As the settlement grows and pressure on land increases, the forest edge is cut back both for building material and to increase the available agricultural land. If a settlement fails, the forest may reclaim this land

Road networks develop. People travel between settlements by the easiest route - but the very fact a route is travelled makes it easier. A path gets cleared; later, people fill in boggy bits and bridge streams, to make their own passage easier or to encourage trade through their lands. Because as a road grows more important, so the settlements along it grow more important, and as the settlements along it grow more important so the roads between them grow more important. The road network, then, is a dynamic fractal which interacts with another dynamic fractal, the distribution of human settlement.
The program I wrote was a cellular automaton which modelled human settlement in only thirty states. It did a remarkably good job. Settlement would spread across a landscape; settlements in strategically beneficial areas would grow faster, develop temples and markets sooner, and thus become important foci of the roads system; other settlements would wax and wane, some falling into ruin; new waves of settlers might settle in slightly different areas.

More states would be better, give a richer, more subtle model, But this demonstrates that it's easy to design a program which will settle a landscape in a realistic way automatically. Once again, though I think it can be done more realistically if it is precomputed and cached rather than if it is generated from the landscape fractal.

In summary: yes, I think it's possible to have an infinite world which is satisfying and can be reproduced at will from a seed, but the stories I want to tell do not call for infinite worlds and if the world is finite I believe it can be made still more satisfyingly realistic by pre-computing and caching things like river systems, afforestation and settlement patterns. Either way, though, the world can be very large - much larger than the worlds of current near-photo-realistic games. The world of The Witcher, for example, is a few hundred hectares; I'm envisaging storing hundreds or thousands of square kilometres in similar data size and with a similar expenditure of artist's effort.

Rendering, and the Flats idea

Rendering a convincing distant view in computer-generated virtual environment is hard. There's an enormous amount of data in a distant view, and if the viewer is moving in real time it becomes computationally unaffordable, even on machines with a great deal of horsepower. Games typically work around this problem by either angling the camera downwards, or else rendering a high degree of atmospheric haze - it's always slightly foggy - so there is never a distant horizon.

Movies shot in studios often have wonderful, detailed backgrounds to their sets. Vistas of far mountains and great cities... of course, the far mountains and great cities don't exist in the set. They're painted on large canvases called 'flats'. The flats illusion depends on the camera not moving too much, because of parallax - nearer things should appear to move relative to further things, and on a flat they don't.

But. But.

For a player moving in a computer game the field of view is quite restricted - it's no more than thirty degrees, typically straight ahead as he moves. Parallax movements are less significant straight ahead. A single flat still isn't going to work, but in many animated films a system of multiple flats is used, with the nearer flat moved relative to the further flat to give an illusion of parallax. This can work very well.
Suppose one projects onto the world a hexagonal grid - it doesn't have to be hexagonal, but I think that is likely to work best - with a cell size of about 100 metres (the exact cell size depends a bit on the speed of movement of the player, for reasons which will become apparent). Cells are grouped into metacells of seven cells (if square, then metacells of nine cells). For each cell, there are six inner flats. Each inner flat consists of a rendering from the centre of the cell of everything more than one cell distant, but less than five cells distant, over a 60 degree arc of view.

For a given area of the world the distant view doesn't change very much. We don't, therefore, have to compute a set of outer flats for every cell, just for every metacell. The outer flats each consist of a rendering of the scenery more than one whole metacell away, from the centre of the metacell.
To render a scene, then, we first paint the outer flat for the metacell the player is in, in the direction the player is looking. Over that we paint the inner flat for the cell the player is in. Over that we render the actual objects in the adjacent cells which fall within the viewing area. Over that we render the objects in the current cell. Thus we only have to render in real time certainly no more objects than can already be rendered by systems which clip for distance either by angling the camera down or by using fog, and yet still manage a realistic distant view.

Rendering the Flats

OK, so when do the flats get rendered? After all, if you're going to pre-render six full colour full screen resolution flats for every hundred metre cell in the world, then either your data volume is going to get enormous or your world is going to get pretty constrained - which was just what we were trying to get away from. And if you're going to multiply that with flats rendered for every time of day and every weather condition - well, it's not feasible.

You cannot realistically pre-render the flats, in my opinion. Or if you can, you're going to have to give them so much real time post processing that you will lose the benefit. Pre-rendering the flats is not the idea. But if they are rendered in real time, where is the benefit...?

There's a middle way. Running straight forward at top speed a player crosses a hundred metre cell in about a minute, during which to give an illusion of continuous movement at least nine hundred full screen frames must have rendered. But the flats don't change in a minute. The flats don't change in five minutes. They don't need to. Even if rain clouds are sweeping across the landscape, it's OK for the distant view still to be sunny five minutes after the rain reaches you, or vice versa. If you can render a high proportion of the detail in a view only once every nine hundred frames, you've saved a lot of processing.

So there is a continuous background process running which renders flats. It does it all the time. It prioritises making sure that a flat exists for every direction the player may look in in the next minute - that is, every direction from the cells and metacells he's currently heading towards. Having done that, it renders flats for cells to either side which he might turn to. It maintains in memory a small stock of flats from recently visited cells, so that if the player turns back they don't have to be repainted in a hurry; and if a flat is more than about five minutes - 4,500 frames - old, it may repaint it to update time-of-day lighting or weather effects.

Obviously, quite a lot of the time the join between two adjacent flats will be in view. I don't see this as a problem. Just naturally, the rendering of the flats should essentially form segments of a hoop, so the join between two adjacent flats should not be perceptible.

Artifacts

Inevitably, there will be undesired artifacts of this system. Significantly, mobile objects - 'non-player characters', the avatars of other players, monsters and computer mediated creatures in the landscape - more than two cells away will not be visible. The flat is static, so it can't have moving characters on it. There may be some algorithmic way round this, since one hundred and fifty metres away is rather close for people to suddenly vanish; but it is not a problem I have a solution for.

Again, if the player is looking sideways as they cross a metacell boundary, there will be a jarring sudden shift in parallax. I acknowledge that and think it just can't be helped; that the benefits in terms of quality of view for given computer power, will render it acceptable.

Wednesday, 27 February 2008

The Witcher: Story telling of a high order

This isn't, by any means, a final review of The Witcher. I've played it fairly intensely over three weeks, and am only into the fourth chapter. Which is great, because there is more to come.

But, what do I think of the show so far?

I'm extraordinarily impressed. I'll come back later to talking about it as a game, but I want to stand back and talk about it in comparison with other media. It's worth comparing it with Kurosawa's Seven Samurai, or - perhaps especially - with Eastwood's High Plains Drifter. It is story telling of the same order, but more than that it is story telling about the same issues; about worlds so tainted with violence and cruelty that all moral actors are tainted. Geralt, the hero whose role you play, is himself a tainted character, edgy, over-aggressive, harsh in judgment. And you will play him like that, no matter how much you want not to. But he's not an amoral character. He's trying to make the best choices he can in a murky and uncertain world.

Again - comparing to cinema, it's only by comparing this with cinema that you can do it justice - the scenery is gorgeous. The quality of the light at dawn and at sunset is just stunning. The trees are so lifelike that you can easily recognise each different species. The representation of a medieval European city, with all its grandeur and all its squalor, is extraordinary. You can almost smell it.

So what is not to like?

Somewhere in the production process a decision was taken that every word spoken by every character should be voice acted - and they are. The voice acting is extremely good (as a Scot, I enjoyed the gag that all the dwarves have Scots accents). It isn't just the significant characters who are voiced, either - people you pass in the street are having conversations with one another, and if you eavesdrop on those conversations you pick up valuable plot clues.

But the decision to voice all the characters has curious effects that aren't entirely good. As a player you expect these beautifully rendered, beautifully spoken characters to have a much richer conversational repertoire than they have. Indeed, I suspect that if the dialogue had been largely text, it would have been economic to provide much richer dialogue.

Most of the characters have been individually modelled - and many are individually motion captured. Old people move rheumatically, children skip, dwarves stomp, whores sway and drunks weave. And that makes the few cases where significant character models are reused (the naiad and the dryad, for example; the cannibal and the fisher king) stand out awkwardly.

Also, and more seriously, I suspect the game's creators have been poorly served by the English translation. Very often the English language dialogue seems anachronistic, over-modern.

Which brings me to the game's Polish roots. I think to fully understand this game and the books on which it is based you need an understanding of Polish history. Yes, it's a fantasy about elves and dwarves and magic. But it's very easy to read the Order of the Flaming Rose as being the Teutonic Order, and the elves and dwarves as the indiginous Prussians and Slavs; or equally, to see the Flaming Rose as being the Nazis (who, after all, consciously emulated the Teutonic Order) and the elves and dwarves as representing the Poles and the Jews. I don't know to what extent that is what the authors intend, but at some level this story is rooted in Poland's long history of genocidal war.

It benefits from that. Its creators understand what genocide means, about how hard it is to stand aside; about the scale and devastation that this sort of war brings. This is a deeply felt story, in a way in which little modern fantasy really is.

For the rest: combat? Yes, if all you want to do is hack and slash this game is not for you. The camera? Yes, sometimes the camera movement is disconcerting. Where in other game engines the game will happily remove walls and whole buildings if they get in the way of the camera, the Witcher's camera manouvers around buildings and trees and sometimes that movement is awkward. To be fair, there are alternative camera was modes available, but I didn't find the camera a problem.

The interactive video game is a young artform. I've been engaged in discussion recently about whether fantasy fiction can ever be literature - needless to say, I argue that it can. Can a video game be literature, or at least art of high quality? Experience the Witcher, and find out

Saturday, 8 December 2007

The best wee act of hegemony in the world

We're all familiar with Jack McConnell's slogan for Scotland's airports. We're all familiar with the incoming nationalist government's dislike of it, and rapid deletion of it. But Jack McConnell must be laughing up his sleeve; we, the nationalists, have missed a trick - badly - and Jack has achieved all he set out to achieve.

Because we didn't challenge the truth of the slogan; we didn't notice that it needed to be challenged. So the idea - the meme - the hegemonic masterstroke that McConnell set out to achieve has been achieved. We have cast our national debate in terms of being a small nation. If you went out in any street in Scotland and asked ten passers by whether Scotland was a big country, a middle sized country, or a small country, all ten would agree, Scotland is 'wee'.

We like the notion. It's romantic, the small band against the world. Our national myth - our stories of Wallace and Bruce are cast as the brave few against the might of a much more powerful hostile world. And so we let it pass unchallenged, and thus give an unnecessary gift to the unionists. Like James the Fourth at Flodden Field, we march down off the strong hill to face our opponents on their territory.

The unionists, of course, are all too happy to present Scotland as a wee nation. Awfy cute, of course; Awfy couthie. But ower wee to stand on its own two feet in the world. Needing the generously offered protection - oh, and 'subsidy' - of our larger, stronger, more viable neighbour.

So what's the truth of it?

Scotland has a population of 5.1 million people.

That's small, isn't it?

No.

Scotland is just slightly smaller than Finland, one hudred and eleventh in the world, and slightly bigger than Turkmenistan, one hundred and twelth. One hundred and twelth? Isn't that awfy far down the league? No, actually, it's not. There are two hundred and twenty one nations and self governing territories in the world, ranging from the Republic of China (1.3 billion people) to the Pitcairn Islands (50 people). One hundred and twelth places us exactly - exactly - in the middle. The median population of all the countries in the world is 5,299,000.

So those 110 countries that are smaller than Scotland, are they all 'too wee' to be viable? Iceland (population 312,851), is that big enough to defend its cod stocks against the combined might of Britain and Spain? Errr... yes, actually. Malta (population 407,000) and Luxembourg (467,000), are they big enough to be full members of the European Union, with seats on the Council of Ministers? Errr... yes, they are, actually.

Looking at the European Union as a whole, Finland, as I said earlier, is just one place up the table from Scotland. Below us are Ireland, Lithuania, Latvia, Slovenia, Estonia and Cyprus, not to mention Malta and Luxembourg. Are all these ower wee to govern themselves? Ower wee to be full members of the European Union? They do not seem to think so. And among our other European neighbours outside the union (and in no hurry to join it) are Iceland (see above), Norway (4,727,777) and Switzerland (slightly bigger than us at 7,508,700). Are they 'ower wee' to stand alone in the world? They, clearly, don't think so.

Indeed, if you look at those three European nations outside the EU, each plays a very significant role in the world. Iceland provided the neutral venue for the USA and the Soviet Union to meet and negotiate the end of the cold war. Norway has made significant and very positive interventions in the Middle East. Switzerland hosts the Red Cross and many United Nations agencies. They can do these things precisely because they're not great powers and don't pretend to be great powers; and thus can be trusted to be honest brokers.

So let's squash this 'small nation' nonsense. Scotland is not 'wee', no matter how couthie and romantic that may feel. Mid table respectability - or mediocrity - is our position, at least on size. We're exactly average. 'The least self-confident medium sized country in the world' may sound a lot less romantic than 'the best wee country', but that's what we are. Medium sized, with well above average resources, well above average potential, well above average wealth. And we lack the courage to take our independence, because we allow other people to characterise us as 'wee'.

It's time that stopped.

Monday, 21 May 2007

Of Size, and Governance


If you set out from Langholm, in Eskdale, and drive in a car to Drummore in the Rhinns of Galloway, you will drive 119 miles, and - according to Google's mapping system - it will take you 4 hours and eight minutes. If you didn't fancy Drummore, you could get to Stafford, in Staffordshire, in one minute less; or Dunkeld, in Perthshire, in five minutes less.
 
From Drummore, driving by road (and taking ferries where appropriate), you could get to Dunoon in Argyle or Dunblane in Perthshire quicker than you could get to Langholm. Even with the ferry, getting to Dundalk in the Republic or Ireland would only take 21 minutes longer.
 
So what's amazing or shocking about that?
 
Well, to get from Langholm to Stafford you pass through Dumfries and Galloway, Cumbria, Lancashire, Manchester, Cheshire and finally Staffordshire. Six separate local government units. To get to Dunkeld you pass through Dumfries and Galloway, South Lanarkshire, Glasgow, East Dumbartonshire, Stirling, and Perth and Kinross; again, six local government areas.
 
To get from Drummore to Dunoon, you pass through five separate local government areas. Drummore to Dunblane is eight...
 
But Drummore to Langholm is only one: Dumfries and Galloway all the way. It's simply a perversion of language that a councillor from Langholm overseeing decisions which affect Drummore (or vice versa) is in any sense 'local' government. Dumfries and Galloway, if it were a nation, would be by no means the worlds smallest. At 6500 square kilometres it's larger than Palestine; larger than Brunei; larger than Trinidad and Tobago; more than twice as large as Samoa or Luxembourg; more than six times as large as Hong Kong; more than ten times as large as Singapore or Bahrain; more than 40 times as large as Liechtenstein; more than four thousand times the size of Monaco. In fact quarter of all the nations and self governing territories in the world have a land area smaller than Dumfries and Galloway.
 
Ah, you might say, but we have a sparse population. That's true, of course. Only 43 nations and self governing territories are less populous than Dumfries and Galloway.
 
But that's talking about nations, about independence. We don't have independence and we don't aspire to it. Let's look at how other small northern European countries organise local democracy. Take Iceland, for example. Iceland has a population twice the size of Dumfries and Galloway. It is divided into 'municipalities' which have responsibility for  kindergartens, elementary schools, waste management, social services, public housing, public transportation, services to senior citizens and handicapped people and so on. Not so very different, in fact, from the responsibilities of our local government. So, with a population twice that of Dumfries and Galloway, how many of these municipalities does Iceland have?
 
Two?
 
No.
 
The answer is seventy nine.
 
Iceland is an extreme case, of course; a nation of proud and independent people with an ancient history of democratic organisation, and strong civil society. But Denmark, with a population roughly equal to Scotland's, has three times as many local authorities. Norway, with three quarters our population, has 400 more local authorities than Scotland has.
 
Put it differently: Dumfries and Galloway has three times the population of the average Danish local authority; four times of the average Swedish or Dutch; twelve times the average for Norway; thirty six times the average for Iceland. I said Iceland was an extreme case, didn't I? Get this. Dumfries and Galloway has eighty four times the population of the average - the average - French commune.



Monday, 20 February 2006

Post-scarcity Software

From http://aturingmachine.com/
For years we've said that our computers were Turing equivalent, equivalent to Turing's machine U. That they could compute any function which could be computed. They aren't, of course, and they can't, for one very important reason. U had infinite store, and our machines don't. We have always been store-poor. We've been mill-poor, too: our processors have been slow, running at hundreds, then a few thousands, of cycles per second. We haven't been able to afford the cycles to do any sophisticated munging of our data. What we stored - in the most store intensive format we had - was what we got, and what we delivered to our users. It was a compromise, but a compromise forced on us by the inadequacy of our machines.

The thing is, we've been programming for sixty years now. When I was learning my trade, I worked with a few people who'd worked on Baby - the Manchester Mark One - and even with two people who remembered Turing personally. They were old then, approaching retirement; great software people with great skills to pass on, the last of the first generation programmers. I'm a second generation programmer, and I'm fifty. Most people in software would reckon me too old now to cut code. The people cutting code in the front line now know the name Turing, of course, because they learned about U in their first year classes; but Turing as a person - as someone with a personality, quirks, foibles - is no more real to them than Christopher Columbus or Noah, and, indeed, much less real than Aragorn of the Dunedain.

In the passing generations we've forgotten things. We've forgotten the compromises we've made; we've forgotten the reasons we've made them. We're no longer poor. The machine on which I'm typing this - my personal machine, on my desk, used by no-one but me - has the processor power of slightly over six thousand DEC VAXes; it has the one hundred and sixty two thousand times as much core store as the ICL 1900 mainframe on which I learned Pascal. Yet both the VAX and the 1900 were powerful machines, capable of supporting dozens of users at the same time. Compared to each individual user of the VAX, of the 1900, I am now incalculably rich. Vastly. Incomprehensibly.

And it's not just me. With the exception of those poor souls writing embedded code for micro-controllers, every programmer now working has processor and store available to him which the designers of the languages and operating systems we still use could not even have dreamed of. UNIX was designed when 32 bit machines were new, when 16,384 bytes was a lot of memory and very expensive. VMS - what we now call 'Windows XP' - is only a few years younger.

The compromises of poverty are built into these operating systems, into our programming languages, into our brains as programmers; so deeply ingrained that we've forgotten that they are compromises, we've forgotten why we chose them. Like misers counting grains on the granary floor while outside the new crop is falling from the stalks for want of harvesting, we sit in the middle of great riches and behave as though we were destitute.

One of the things which has made this worse in recent years is the rise of Java, and, following slavishly after it, C#. Java is a language which was designed to write programs for precisely those embedded micro-controllers which are still both store and mill poor. It is a language in which the mind-set of poverty is consciously ingrained. And yet we have adopted it as a general purpose programming language, something for which it is not at all suitable, and in doing so have taught another generation of programmers the mind-set of poverty. Java was at least designed; decisions were made for reasons, and, from the point of view of embedded micro-controllers, those reasons were good. C# is just a fit of pique as software. Not able to 'embrace and extend' Java, Microsoft aped it as closely as was possible without breaching Sun's copyright. Every mistake, every compromise to poverty ingrained in Java is there in C# for all the world to see.

It's time to stop this. Of course we're not as wealthy as Turing. Of course our machines still do not have infinite store. But we now have so much store - and so many processor cycles - that we should stop treating them as finite. We should program as if we were programming for U.

Store, Name and Value

So let's start with what we store, what we compute on: values. For any given column within a table, for every given instance variable in a class, every record, every object is constrained to have a value with a certain format.

This is, of course, historical. Historically, when storage was expensive we stored textual values in fields of fixed width to economise on storage; we still do so largely because that's what we've always done rather than because there's any longer any rational reason to. Historically, when storage and computation were expensive, we stored numbers in twos-complement binary strings in a fixed number of bytes. That's efficient, both of store and of mill.

But it is no longer necessary, nor is it desirable, and good computer languages such as LISP transparently ignores the difference between the storage format of different numbers. For example:

(defun factorial (n)
  (cond 
    ((eq n 1) 1)
    (t (* n (factorial (- n 1))))))

;; a quick way to generate very big numbers...

We can add the value of factorial 100 to an integer, say 2, in just
the same way that we can add any other two numbers:

(+ (fact 100) 2)
933262154439441526816992388562667004907159682643816214685929638952 175999932299156089414639761565182862536979208272237582511852109168 64000000000000000000000002

We can multiply the value of factorial 100 by a real number, say pi, in just the same way as we can add any other two numbers:

(* (factorial 100) pi)
2.931929528260332*10^158

The important point to note here is that there's no explicit call to a bignum library or any other special coding. LISP's arithmetic operators don't care what the underlying storage format of a number is, or rather, are able transparently to handle any of the number storage formats - including bignums - known to the system. There's nothing new about this. LISP has been doing this since the late 1960s. Which is as it should be, and, indeed, as it should be in storage as well as in computation.

A variable or a database field (I'll treat the two as interchangeable, because, as you will see, they are) may reasonably have a validation rule which says that a value which represents the longitude of a point on the Earth in degrees should not contain a value which is greater than 360. That validation rule is domain knowledge, which is a good thing; it allows the system to have some vestige of common sense. The system can then throw an exception when it is asked to store 764 as the longitude of a point, and this is a good thing.

Why then should a database not throw an exception when, for example, a number is too big to fit in the internal representation of a field? To answer, here's a story I heard recently, which seems to be apocryphal, but which neatly illustrates the issue just the same.
The US Internal Revenue Service have to use a non-Microsoft computer to process Bill Gate's income tax, because Microsoft computers have too small an integer representation to represent his annual income.
Twos complement binary integers stored in 32 bits can represent plus or minus 2,147,483,648, slightly over two US billion. So it's easily possible that Bill Gates' income exceeds this. Until recently, Microsoft operating systems ran only on computers with a register size of 32 bits. Worryingly, the default integer size of my favourite database, Postgres, is also 32 bits.

This is just wrong. Nothing in the domain of income places any fixed upper bound on the income a person may receive. Indeed, with inflation, the upper limit on incomes as quantity is likely to continue to rise. Should we patch the present problem by upping the size of the integer to eight bytes?
In Hungary after the end of World War II inflation ran at 4.19 ? 1016 percent per month - prices doubled every 15 hours. Suppose Gates' income in US dollars currently exceeds the size of a thirty two bit integer, it would take at most 465 hours - less than twenty days - to exceed US$9,223,372,036,854,775,808. What's scary is how quickly you'd follow him. If your present annual salary is just thirty three thousand of your local currency units, then given that rate of inflation, you would overflow a sixty-four bit integer in just 720 hours, or less than a month.

Lots of things in perfectly ordinary domains are essentially unbounded. They aren't shorts. They aren't longs. They aren't doubles. They're numbers. And a system asked to store a number should store a number. Failure to store a number because it's size violates some constraint derived from domain knowledge is desirable behaviour; failure to store a number because it size violates the internal storage representation of the system is just bad, outdated, obsolete system design. Yes, it's efficient of compute power on thirty-two bit processors to store values in thirty-two bit representations. Equally, it's efficient of disk space for a database to know in advance just how mush disk it has to reserve for each record in a table, so that to skip to the Nth record it merely has to skip forward (N * record-size) bytes.

But we're no longer short of either processor cycles or disk space. For a database to reject a value because it cannot be stored in a particular internal representation is industrial archaeology. It is a primitive and antiquated workaround from days of hardware scarcity. In these days of post-scarcity computing, it's something we should long have forgotten, long have cast aside.

This isn't to say that integers should never be stored in thirty-two bit twos complement binary strings. Of course they should, when it's convenient to do so. It's a very efficient storage representation. Of course, when a number overflows a thirty two bit cell, the runtime system has got to throw an exception, has got to deal with it, and consequently the programmer who writes the runtime system has still got to know about and understand the murky aspects of internal storage formats.

Perhaps the language designer, and the programmer who writes the language compiler should, too, but personally I don't think so. I think that at the layer in the system - the level of abstraction - at which the compiler writer works, the operator 'plus' should just be a primitive. It takes two numbers, and returns a number. That's all. The details of whether that's a float, a double, a rational or a bignum should not be in the least relevant at the level of language. There is a difference which is important between a real number and an integer. The old statistical joke about the average family having 2.4 children is funny precisely because it violates our domain knowledge. No family has 2.4 children. Some things, including children, are discrete, however indiscreet you may think them. They come in integral quantities. But they don't come in short quantities or long quantities. Shorts and longs, floats and doubles are artefacts of scarcity of store. They're obsolete.

From the point of view of the runtime designer, the difference between a quantity that can be stored in two bytes, or four, or eight must matter. From the point of view of the application designer, the language designer, even the operating system designer, they should disappear. An integer should be an integer, whether it represents the number of toes on your left foot (about 5), the number of stars in the galaxy (about 1x1011) or the number of atoms in the universe (about 1x1079). Similarly, a real number should be just a real number.

This isn't to say we can't do data validation. It isn't to say we can't throw a soft exception - or even a hard one - when a value stored in a variable or field violates some expectation, which may be an expectation about size. But that should be an expectation based on domain knowledge, and domain knowledge alone; it should not be an expectation based on implementation knowledge.

Having ranted now for some time about numbers, do you think I'm finished? I'm not. We store character values in databases in fields of fixed size. How big a field do we allocate for someone's name? Twenty four characters? Thirty-two? We've all done it. And then we've all found a person who violates our previous expectation of the size of a name, and next time we've made the field a little bigger. But by the time we've made a field big enough to store Charles Philip Arthur George Windsor or Sirimavo Ratwatte Dias Bandaranaike we've negated the point of fixed width fields in the first place, which was economy. There is no natural upper bound to the length of a personal name. There is no natural upper bound to the length of a street address. Almost all character data is a representation at some level of things people say, and the human mind doesn't work like that.

Of course, over the past fifty years, we've tried to make the human mind work like that. We've given addresses standardised 'zip codes' and 'postcodes', we've given people standardised 'social security numbers' and 'identity codes'. We've tried to fit natural things into fixed width fields; we've tried to back-port the inadequacies of our technology onto the world. It's stupid, and it's time we stopped.

So how long is a piece of string? How long is a string of characters? It's unbounded. Most names are short, because short names are convenient and memorable. But that does not mean that for any given number of characters, it's impossible that there should be something with a normal name of that length. And names are not the only things we store in character strings. In character strings we store things people say, and people talk a lot.

At this point the C programmers, the Java programmers are looking smug. Our strings, they say, are unbounded. Sorry lads. A C string is a null terminated sequence of bytes. It can in principle be any length. Except that it lives in a malloced lump of heap (how quaint, manually allocating store) and the maximum size of a lump of heap you can malloc is size_t, which may be 231, 232, 263 or 264 depending on the system. Minus one, of course, for the null byte. In Java, similarly, the size of a String is an int, and an int, in Java, means 231.

Interestingly, Paul Graham, in his essay 'The Hundred YearLanguage', suggests doing away with stings altogether, and representing them as lists of characters. This is powerful because strings become S-expressions and can be handled as S-expressions; but strings are inherently one-dimensional and S-expressions are not. So unless you have some definite collating sequence for a branching 'string' it's meaning may be ambiguous. Nevertheless, in principle and depending on the internal representation of a CONS cell, a list of characters can be of indefinite extent, and, while it isn't efficient of storage, it is efficient of allocation and deallocation; to store a list of N characters does not require us to have a contiguous lump of N bytes available on the heap; nor does it require us to shuffle the heap to make a contiguous lump of that size available.

So; to reprise, briefly.

A value is just a value. The internal representation of a value is uninteresting, except to the designer and author of the runtime system - the virtual machine. For programmers at every other level the internal representation of every value is DKDC: don't know, don't care. This is just as true of things which are fundamentally things people say, things which are lists and things which are pools, as it is of numbers. The representation that the user - including the programmer - deals with is the representation which is convenient and comfortable. It does not necessarily have anything to do with the storage representation; the storage representation is something the runtime system deals with, and that the runtime system effectively hides. Operators exposed by the virtual machine are operators on values. It is a fundamental error, a failure of the runtime designer's most basic skill and craft, for a program ever to fail because a value could not be represented in internal representation - unless the store available to the system is utterly exhausted.

Excalibur and the Pool

A variable is a handle in a namespace; it gives a name to a value, so that we can recall it. Storing a value in a variable never causes an exception to be thrown because the value cannot be stored. But it may, reasonably, justifiably, throw an exception because the value violates domain expectations. Furthermore, this exception can be either soft or hard. We might throw a soft exception if someone stored, in a variable representing the age of a person in years, the value 122. We don't expect people to reach one hundred and twenty two years of age. It's reasonable to flag back to whatever tried to set this value that it is out of the expected range. But we should store it, because it's not impossible. If, however, someone tries to store 372 in a variable representing longitude in degrees, we should throw a hard exception and not store it, because that violates not merely a domain expectation but a domain rule.

So a variable is more than just a name. It is a slot: a name with some optional knowledge about what may reasonably be associated with itself. It has some sort of setter method, and possibly a getter method as well.

I've talked about variables, about names and values. Now I'll talk about the most powerful abstraction I use - possibly the most powerful abstraction in software - the namespace. A namespace is a sort of pool into which we can throw arbitrary things, tagging each with a distinct name. When we return to the pool and invoke a name, the thing in the pool to which we gave that name appears.

Regularities: tables, classes, patterns

Database tables, considered as sets of namespaces, have a special property: they are regular. Every namespace which is a record in the same table has the same names. A class in a conventional object oriented language is similar: each object in the class has the same set of named instance variables. They match a pattern: they are in fact constrained to match it, simply by being created in that table or class.
Records in a table, and instance variables in a class, also have another property in common. For any given name of a field or instance variable, the value which each record or object will store under that name is of the same type. If 'Age' is an integer in the definition of the table or class, the Age of every member will be an integer. This property is different from regularity, and, lacking a better word for it, I'll call it homogeneity. A set of spaces which are regular (i.e. share the same names) need not be homogeneous (i.e. share the same value types for those names), but a set which is homogeneous must be regular.

But records in a table, in a view, in a result set are normally in themselves values whose names are the values of the key field. And the tables and views, too, are values in a namespace whose names are the table names, and so on up. Namespaces, like Russian dolls, can be nested indefinitely. By applying names to the nested spaces at each level, we can form a path of names to every space in the meta-space and to each value in each space, provided that the meta-space forms an acyclic directed graph (this is, after all, the basis of the XPath language. Indeed, we can form paths even if the graph has cycles, provided every cycle in the graph has some link back to the root.

Social mobility

It's pretty useful to gather together all objects in the data space which match the same pattern; it's pretty useful for them all to have distinct names. So the general concept of a regularity which is itself a namespace is a useful one, even if the names have to be gensymed.

To be in a class (or table), must a space be created in that class (or table)? I don't see why. One of my earlier projects was an inference engine called Wildwood, in which objects inferred their own class by exploring the taxonomy of classes until they found the one in which they felt most comfortable. I think this is a good model. You ought to be able to give your dataspace a good shake and then pull out of it as a collection all the objects which match any given pattern, and this collection ought to be a namespace. It ought to be so even if the pattern did not previously exist in the data space as the definition of a table or class or regularity or whatever you care to call it.

A consequence of this concept is that objects which acquire new name-value pairs may move out of the regularity in which they were created either to exist as stateless persons in the no-man's land of the dataspace, or into a new regularity; or may form the seed around which a new regularity can grow. An object which acquires a value for one of its names which violates the validation constraints of one homogeneity may similarly move out into no-man's land or into another. In some domains, in some regularities, it may be a hard error to do this (i.e. the system will prevent it). In some domains, in some regularities, it may be a soft error (i.e. the system allows it under protest). In some domains, in some regularities, it may be normal; social mobility of objects will be allowed.

Permeability

There's another feature of namespaces which gets hard wired into lots of software structures without very often being generalised, and that is permeability, semi-translucency. In my toolkit Jacquard, for example, values are first searched for in the namespace of http parameters; if not found there, in the namespace of cookies; next, in the namespace of session variables, then in local configuration parameters, finally in global configuration parameters. There is in effect a layering of semi-translucent namespaces like the veils of a dancer.

It's not a pattern that's novel or unique to Jacquard, of course. But in Jacquard it's hard wired and in all the other contexts in which I've seen this pattern it's hardwired. I'd like to be able to manipulate the veils; to add, or remove, of alter the layering. I'd like this to be a normal thing to be able to do.

The Name of the Rose: normativeness and hegemony

I have a friend called Big Nasty. Not everyone, of course, calls him Big Nasty. His sons call him 'Dad'. His wife calls him 'Norman'. People who don't know him very well call him 'Mr Maxwell'. He does not have one true name.

The concept of a true name is a seductive one. In many of the traditions of magic - and I have always seen software as a technological descendant or even a technological implementation of magic - a being invoked by its true name must obey. In most modern programming languages, things tend to have true names. There is a protocol for naming Java packages which is intended to guarantee that every package written anywhere in the world has a globally unique true name. Globally unique true names do then have utility. It's often important when invoking something to be certain you know exactly what it is you're invoking.

But it does not seem to me that this hegemonistic view of the dataspace is required by my messy conception. Certainly it cannot be true that an object has only one true name, since it may be the value of several names within several spaces (and of course this is true of Java; a class well may have One True Name, but I can still create an instance variable within an object whose name is anythingILike, and have its value is that class).

The dataspace I conceive is a soup. The relationships between regularities are not fixed, and so paths will inevitably shift. And in the dataspace, one sword can be in many pools - or even many times in the same pool, under different names - at the same time. We can shake the dataspace in different ways to see different views on the data. There should be no One True hegemonistic view.

This does raise the question, 'what is a name'. In many modern relational databases, all primary keys are abstract and are numbers, even if natural primary keys exist in the data - simply because it is so easy to create a table with an auto-incrementer on the key field. Easy, quick, convenient, lazy, not always a good thing. In terms of implementation details, namespaces are implemented on top of hash tables, and any data object can be hashed. So can anything be a name?

In principle yes. However, my preference would be to purely arbitrarily say no. My preference would be to say that a name must be a 'thing people say', a pronounceable sequence of characters; and also, with no specific upper bound, reasonably short.

The Problem with Syntax

Let me start by saying that I really don't understand the problem with syntax. Programming language designers spend a lot of time worrying about it, but I believe they're simply missing the point. People say 'I can't learn LISP because I couldn't cope with all the brackets'. People - the Dylan team, for one - have developed systems which put a skin of 'normal' (i.e., ALGOL-like) syntax on top of LISP. I personally won't learn Python because I don't trust a language where white space is significant. But in admitting that prejudice I'm admitting to a mistake which most software people make.

We treat code as if it wasn't data. We treat code as if it were different, special. This is the mistake made by the LISP2 brigade, when they gave their LISPs (ultimately including Common LISP) separate namespaces, one for 'code' and one for 'data'. It's a fundamental mistake, a mistake which fundamentally limits our ability to even think about software.

What do I mean by this?

Suppose I ask my computer to store pi, 3.14159265358979. Do I imagine that somewhere deep within the machine there is a bitmap representation of the characters? No, of course I don't. Do I imagine there's a vector starting with the bytes 50 46 49 51 49 53 57 ...? Well, of course, there might be, but I hope there isn't because it would be horribly inefficient. No, I hope and expect there's an IEEE 754 binary encoding of the form 01100100100001111...10. But actually, frankly, I don't know, and I don't care, provided that it is stored and that it can be computed with.

However, as to what happens if I then ask my computer to show me the value it has stored, I do know and I do care. I expect it to show me the character string '3.14159265358979' (although I will accept a small amount of rounding error, and I might want it to be truncated to a certain number of significant figures). The point is, I expect the computer to reflect the value I have stored back to me in a form which it is convenient for me to read, and, of course, it can.

We don't, however, expect the computer to be able to reflect back an executable for us in a convenient form, and that is in itself a curious thing. If we load, for example, the UNIX command 'ls' into a text editor, we don't see the source code. We see instead, the raw internal format. And the amazing thing is that we tolerate this.

It isn't even that hard to write a 'decompiler' which can take a binary and reflect back source code in a usable form. Here, for example, is a method I wrote:

    /**
     * Return my action: a method, to allow for specialisation. Note: this
     * method was formerly 'getAction()'; it has been renamed to disambiguate
     * it from 'action' in the sense of ActionWidgets, etc.
     */
    public String getNextActionURL( Context context ) throws Exception
    {
        String nextaction = null;

        HttpServletRequest request =
            (HttpServletRequest) context.get( REQUESTMAGICTOKEN );

        if ( request != null )
        {
            StringBuffer myURL = request.getRequestURL(  );

            if ( action == null )
            {
                nextaction = myURL.toString(  );

                // If I have no action, default my action
                // to recall myself
            }
            else
            {
                nextaction =
                    new URL( new URL( myURL.toString(  ) ), action ).toString(  );

                // convert my action into a fully
                // qualified URL in the context of my
                // own
            }
        }
        else
        { // should not happen!
            throw new ServletException( "No request?" );
        }

        return nextaction;
    }

and here is the result of 'decompiling' that method with an
open-source Java decompiler, jreversepro:

    public String getNextActionURL(Context context)
                throws Exception
    {
         Object object = null;
         HttpServletRequest httpservletrequest = 
              (HttpServletRequest)context.get( "servlet_request");
         String string;
         if (httpservletrequest != null) {
              StringBuffer stringbuffer = httpservletrequest.getRequestURL();
              if (action == null)
                   string = stringbuffer.toString();
              else
                   string = new URL(new URL(stringbuffer.toString()) ,
                                    action).toString();
         }
         else
              throw new ServletException("No request?");

         return (string);
    }

As you can see, the comments have been lost and some variable names
have changed, but the code is essentially the same and is perfectly
readable. And this is with an internal form which has not been
designed with decompilation in mind. If decompilation had been designed
for in the first place, the binary could have contained pointers to
the variable names and comments. Historically we haven't done this,
both for 'intellectual property' reasons and because of store
poverty. In future, we can and will.

Again, like so much in software, this isn't actually new. The microcomputer BASICs of the seventies and eighties 'tokenised' the source input by the user. This tokenisation was not of course compilation, but it was analogous to it. The internal form of the program that was stored was much terser then the representation the user typed. But when the user asked to list the program, it was expanded into its original form.

Compilation - even compilation into the language of a virtual machine - is much more sophisticated than tokenising, of course. Optimisation means that many source constructs may map onto one object construct, and even that one source construct may in different circumstances map onto many object constructs. Nevertheless it is not impossible - nor even hugely difficult - to decompile object code back into readable, understandable and editable source.

But Java syntax is merely a format. When I type a date into a computer, say '05-02-2005', and ask it to reflect that date back to me, I expect it to be able to reflect back to me '05-02-2006'. But I expect it to be able to reflect back to an American '02-05-2006', and to either of us 'Sunday 5th February 2006' as well. I don't expect the input format to dictate the output format. I expect the output format to reflect the needs and expectations of the person to whom it is displayed.

To summarise, again.

Code is data. The internal representation of data is Don't Know, Don't Care. The output format of data is not constrained by the input format; it should suit the use to which it is to be put, the person to whom it is to be displayed.

Thus if the person to whom my Java code is reflected back is a LISP programmer, it should be reflected back in idiomatic LISP syntax; if a Python programmer, in idiomatic Python syntax. Let us not, for goodness sake, get hung up about syntax; syntax is frosting on the top. What's important is that the programmer editing the code should edit something which is clearly understandable to him or her.

This has, of course, a corollary. In InterLISP, one didn't edit files 'out of core' with a text editor. One edited the source code of functions as S-expressions, in core, with a structure editor. The canonical form of the function was therefore the S-expression structure, and not the printed representation of it. If a piece of code - a piece of executable binary, or rather, of executable DKDC - can be reflected back to users with a variety of different syntactic frostings, none of these can be canonical. The canonical form of the code, which must be stored in version control systems or their equivalent, is the DKDC itself; and to that extent we do care and do need to know, at least to the extent that we need to know that the surface frosting can again be applied systematically to the recovered content of the archive.

If God does not write LISP

I started my professional life writing LISP on Xerox 1108s and, later, 1186s - Dandelions and Daybreaks, if you prefer names to numbers. When I wanted to multiply two numbers, I multiplied two numbers. I didn't make sure that the result wouldn't overflow some arbitrary store size first. When a function I wrote broke, I edited in its structure in its position on the stack, and continued the computation. I didn't abort the computation, find a source file (source file? How crude and primitive), load it into a text editor, edit the text, save it, check for syntax errors, compile it, load the new binary, and restart the computation. That was more than twenty years ago. It is truly remarkable how software development environments have failed to advance - have actually gone backwards - in that time.

LISP's problem is that it dared to try to behave as though it were a post-scarcity language too soon. The big LISP machines - not just the Xerox machines, the LMI, Symbolics, Ti Explorer machines - were vastly too expensive. My Daybreak had 8Mb of core and 80Mb of disk when PCs usually didn't even have the full 640Kb. They were out-competed by UNIX boxes from Sun and Apollo, which delivered less good software development environments but at a much lower cost. They paid the price for coming too early: they died. And programmers have been paying the price for their failure ever since.

But you only have to look at a fern moss, a frond of bracken, an elm sapling, the water curling over the lip of a waterfall, to know that if God does not write LISP He writes some language so similar to LISP as to make no difference. DNA encodes recursive functions; turbulent fluids move in patterns formed by recursion, whorls within whorls within whorls.

The internal structure, then, of the post scarcity language is rather lisp-like. Don't get hung up on that! Remember that syntax isn't language, that the syntax you see need not be the syntax I see. What I mean by saying the language is lisp-like is that its fundamental operation is recursion, that things can easily be arranged into arbitrary structures, that new types of structure can be created on the fly, that new code (code is just data, after all) can be created and executed on the fly, that there is no primacy of the structures and the code created by the programmer over the structures and code created by the running system; that new code can be loaded and linked seamlessly into a running system at any time. That instead of little discrete programs doing little discrete specialised things in separate data spaces each with its own special internal format and internal structures, the whole data space of all the data available to the machine (including, of course, all the code owned by the machine) exists in a single, complex, messy, powerful pool. That a process doesn't have to make a special arrangement, use a special protocol, to talk to another process or to exchange data with it.

In that pool, the internal storage representation of data objects is DKDC. We neither have nor need to have access to it. It may well change over time without application layer programs even being aware or needing to be aware of the change, certainly without them being recompiled.

The things we can store in the dataspace include:


  • integers of any size
  • reals to any appropriate degree of precision
  • rationals, complex numbers, and other things we might want to compute with
  • dates, times, and other such useful things
  • things people say of any extent, from names to novels
  • lists of any extent, branching or not, circular or not
  • slots associations of names with some setter and, perhaps, getter knowledge which determine what values can be stored under that name
  • namespaces collections, extensible or not, of slots
  • regularities collections of namespaces each of which share identical names
  • homogeneities collections of namespaces each of which share identical slots
  • functions all executable things are 'functions' in a lispy sense. They are applied to arguments and return values. They may or may not have internal expectations as to the value type of those arguments.
  • processes I don't yet have a good feeling for what a post-scarcity process looks like, at top level. It may simply be a thread executing a function; I don't know. I don't know whether there needs to be one specially privileged executive process.


Things which we no longer store - which we no longer store because they no longer have any utility - include


  • shorts, longs, doubles, etc specific internal representation types. You saw that coming.
  • tables, and with them, relational databases and relational database management systems no longer needed because the pool is itself persistent (although achieving the efficiency of data access that mature RDBMS give us may be a challenge).
  • files You didn't see that coming?


Files are the most stupid, arbitrary way to store data. Again, with a persistent data pool, they cease to have any purpose. Post scarcity, there are no files and there is no filesystem. There's no distinction between in core and out of core. Or rather, if there are files and a filesystem, if there is a distinction between in core and out of core, that distinction falls under the doctrine of DKDC: we don't know about it, and we don't care about it. When something in the pool wants to use or refer to another something, then that other something is available in the pool. Whether it was there all along, or whether it was suddenly brought in from somewhere outside by the runtime system, we neither know nor care. If things in the pool which haven't been looked at for a long time are sent to sulk elsewhere by the runtime system that is equally uninteresting. Things which are not referenced at all, of course, may be quietly dropped by the runtime system in the course of normal garbage collection.

One of the things we've overloaded onto the filesystem is security. In core, in modern systems, each process guards its own pool of store jealously, allowing other processes to share data with it only through special channels and protocols, even if the two processes are run by the same user identity with the same privilege. That's ridiculous. Out of core, data is stored in files often with inscrutable internal format, each with its own permissions and access control list.

It doesn't need to be that way. Each primitive data item in core - each integer, each list node, each slot, each namespace - can have its own access control mechanism. Processes, as such, will never 'own' data items, and will certainly never 'own' chunks of store - at the application layer, even the concept of a chunk of store will be invisible. A process can share a data item it has just created simply by setting an appropriate access policy on it, and programmers will be encouraged normally to be as liberal in this sharing as security allows. So the slot Salary of the namespace Simon might be visible only to the user Simon and the role Payroll, but that wouldn't stop anyone else looking at the slot Phone number of the same namespace.

Welcome, then, to post scarcity computing. It may not look much like what you're used to, but if it doesn't it's because you've grown up with scarcity, and even since we left scarcity behind you've been living with software designed by people who grew up with scarcity, who still hoard when there's no need, who don't understand how to use wealth. It's a richer world, a world without arbitrary restrictions. If it looks a lot like Alan Kay (and friends)'s Croquet, that's because Alan Kay has been going down the right path for a long time.

Creative Commons Licence
The fool on the hill by Simon Brooke is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License