Monday, 22 June 2009

The midsummer report

While midsummer eve was as cold and foggy as any I can remember, these following days have been beautiful. The winds are still a bit chilly, which can be deceptive since it makes you forget how much sun you're actually exposing your poor skin to. I spent most of a day mowing the grass around the house, and got myself a really superb redneck tan.

An hour or two ago, a White-tailed eagle circled a few times over our house, as usual supremely unimpressed by the gang of annoyed seagulls that tried to chase it away. A cuckoo is, well, cuckooing, in the distance, and the water is glittering. In fact, it's bloody hard to get any real work done in a place like this.

Over and out.

Wednesday, 3 June 2009


When I planned my trip to California for the Erlang Factory conference, I followed a friend's advice and set aside a couple of days to go and see Yosemite Valley. I don't regret it - it was absolutely fantastic. Yosemite is about 4 hours drive east from San Francisco, up in the high Sierra Nevadas, and it's one of the most stunning landscapes you can imagine. Nothing I had read about it beforehand had prepared me for the feeling of actually being there and seeing this amazing valley in real life; not even Google Earth (although I recommend trying that for yourself - the 3D detail is really good). Of course I took a lot of photos, but it's not until now that I'm done going through the lot of them (discarding more than half), so I've waited with writing about the trip.

I stayed two nights in Curry Village, a camp site of permanent tent-cabins (complete with beds, but no heat) that are the cheapest option if you don't bring your own camping equipment and want to stay one or more nights in the valley. ("Cheap" of course being relative in a place like this; a night at the Ahwahnee Hotel will set you back $500, off season.) Since this was at the end of April - the 27th to 29th, more specifically - the nights could still be cold, but from what I could see on the web before the trip, it seemed like it would not be colder than 5-10 degrees centigrade. Well, it turned out that the 28th was a brilliant day followed by a clear, cold night, as can be seen from the graph here. My sleeping bag was not quite up to the task, and I can't remember ever shivering so much in the wee hours. Still no regrets, though.

One of the things with visiting Yosemite is that you get a whole load of instructions from pretty much everywhere about how to keep anything with a smell (food and other things) stored safely to avoid problems with bears breaking in to cars, tents, etc. It's still not likely that you'll actually see a bear, but they can come roaming around the camp in the nighttime, they have an acute sense of smell, and have been known to even bend up car doors. So, on the day I arrived, I made sure to empty the car and put everything in the bear-safe locker, but there was a fair amount of activity around and it didn't really feel like any bears would ever come near the place. After getting settled, I walked over to the food pavilion to grab some dinner, and with the sun beginning to fade, I went for a stroll afterwards to see a bit of the place before dark. Following the edge of a part of the camp that had been blocked off due to some rock slides earlier, I walked for just a few minutes, and as I stopped and looked up among the trees and boulders, I suddenly realized that I was looking straight at a bear. Less than 100 meters away, I'm sure it was quite aware of me, but it didn't so much as dignify me with a look, not even when I took some pictures. It just slowly sauntered away, apparently circling the camp. A good start to the visit, I thought.

I didn't have any specific plan for the next day; I had simply brought my walking shoes and thought I'd improvise. Mainly, I expected to follow some simple trail around the valley floor, looking up at all the scenery. On a whim, though, I dropped by the hiking equipment store after breakfast and asked one of the guys there if he could recommend any particular trail and maybe sell me a map. Thanks to him, I decided to go on a route marked as "very strenuous", all the way to the top of the Upper Yosemite Fall, which he said was perfect for the season (spring being when the waterfalls are the most spectacular) and would give me superb views, much better than from the bottom of the valley. So with a map in hand, off I went towards the start of that trail, picking up some food and drink on the way. It was a brilliant day, and instead of trying to describe the hike here, I'll just point you to the pictures I took. I started out around 10 in the morning, was up on the top at midday, and got back down again at four, very tired but happy.

After the second, very cold night in Curry Village, I had to drive back to San Francisco again, but first I made a stop at one of the few places where you can see giant sequoia trees. They were quite impressive, but I think the feeling that remained with me was one of sadness - none of the surviving trees were nearly as grand as the ones you could see in the black-and-white photographs on the signs, with lumberjacks posing beside huge sequoias that they were in the process of chopping down.

Saturday, 16 May 2009

SF and Alcatraz

A couple of weeks ago, I went to San Francisco for the Bay Area Erlang Factory. The conference was great, but I also took a few days off to be able to do some touristy things on my own first (not to mention working off the 9 hour jet lag). I had a lazy sunday in SF and took the opportunity to visit Alcatraz for the first time. I was really lucky with the weather and took a whole bunch of photos.

Thursday, 2 April 2009

News for nerds

"The Implementation of Functional Programming Languages", the classic book by Simon Peyton-Jones (et al.) has been out of print for years, but has now been released as a free book in several juicy formats. Just follow the link.

Wednesday, 18 February 2009

Erlang Text Elite

This last weekend, I somehow came to think about the wonderful old space trading game Elite, and the way it managed to cram a vast universe of planets with names, stats, and fun descriptions (along with the 3D space flight simulation, which was an amazing feat in itself) into the tiny 8-bit home computers of old. Only minutes later, I had found Ian Bell's Text Elite web page, where Ian, one of the two original authors of the game, has published a reconstruction in C of the main universe-generating algorithm, along with a simple text interface to actually let you "play", i.e., buy, sell, and jump between planets. Great!

So I rewrote it in Erlang. And had a lot of fun doing it. Apart from the nostalgic kick, there were two points with the exercise: First of all, I just wanted to see the main algorithm as cleanly implemented as possible. But second, I wanted to see what it would be like to rewrite a piece of classic game code that was very clearly not written with functional programming in mind (though of course already cleaned up a bit by being rewritten in C from the original 6502 assembler). I think I like how the result turned out; it's quite clean and readable, and the data flows are easy to follow. I also found and fixed a bug in the "goat soup" function.

The code can be found on GitHub, along with the two scripts for testing found on Ian's page. You can run them like this:
erl -noshell -s txtelite main -s init stop < sinclair.txt
(To play yourself, just skip the last "< sinclair.txt" part.) Of course, you need to compile the txtelite.erl file first. If you're new to Erlang, this is how:
erlc txtelite.erl
It's good to be back on Lave again!

Monday, 9 February 2009


Lately (well, for almost a year now), I've been watching a whole lot of the British TV series "Time Team". If you've never heard about it, it's a show about archaeology. Before you fall asleep, let me assure you that it is as far removed as possible from any boring documentaries you have may watched (you know, the ones with a voice that drones on and on about some kings and battles with a slideshow of still pictures for illustration). No, this is a show about digging. Also, the fact that it's been running since 1994 should tell you something of its popularity.

The idea of the show is to follow a "crack team" of professional archaeologists over three days, as they attack a particular site of interest. The sites are chosen based on various sources, from previously known places where some finds have been made before (but no proper investigation has been done), to the back garden of some family who found something strange when they were buring their cat. Sometimes the target is ancient, even prehistoric, and sometimes it can be from the WWII era. There is a huge variation in material covered, and although not every episode can be spectacular (but many are!), out of some 150+ regular episodes so far, they tend to range from fairly interesting to jaw-droppingly incredible.

In my mind, it is possibly the ideal TV program; an optimal use of the medium, and immensely entertaining, educating, and enlightening. But it is also simply a lot of fun, with much banter and fun-poking going on between people who combine vast amounts of knowledge with sharp wit in that relaxed manner of the British. In fact, probably no other country could succeed with such a show, without either turning it into an acedemic pissing contest (consider the French), a testosteron-filled infotainment show (the Americans), or just a bleak and humourless educational program (the Germans, or the Swedes for that matter). The Brits, on the other hand, will stay focused on getting the facts, but at the same time remain relaxed and optimistic, tease each other a lot, and continue the discussion over a pint down at the pub.

Of course, Britain is also an ideal country for archaeology, with its multilayered history of Celts, Romans, Saxons, Vikings, Normands, knights and castles, Tudor mansions, catholics and protestants, civil war, industrial revolution, Georgian manors, WWII fortifications, and whatnot. There are also lots of old documents, including what is known from Roman sources during the occupation, the Anglo-Saxon Chronicle that refers to events as far back as 60 BC, and the important Domesday Book survey of England from 1086. In comparison, we hardly have any solid facts at all about Sweden before 1100, much less a complete list of who owned what.

The program host, who explains what is going on but also functions as the viewers' representative who runs around and asks all the silly questions, is Tony Robinson, also known as Baldrick of the 1980s comedy series Blackadder, and he is perfect for the job. Like Watson to Sherlock Holmes, he is no fool, but without him the audience would not have any way to follow what is going on. It is probably safe to say that the show would not have been a success without him, the way he alternates between radiating enthusiasm for the subject and the potential discoveries at hand, and expressing dismay at the lack of interesting finds and slagging off the archaeologists when all they have found is a few ancient post-holes and stones - which of course forces the archaeologists to explain exactly why these finds really are interesting and what conclusions you can draw from them, which was the whole point.

But it's also the people themselves that make the program so much fun. Apart from Tony Robinson, we have:
  • Professor Mick Aston, the team captain and benevolent dictator, with all the dress sense of a... well, of a British archaology professor who likes multicoloured knitwear. Always cheerfully optimistic even when it's the afternoon of the last day, they've found almost nothing, and a storm is approaching.
  • The inimitable Phil Harding with his hat, wild hair and whiskers, and a West Country accent which could be called "broad" in the same way that the Chinese Wall could be called "long". Never happier than with a shovel or trowel in hand, unless it's a piece of flint, or even better, a beer. Frequent exclamations of "ooh, ah!", "ooh, look at that!", and the occasional "stone the crows!"
  • Stewart Ainsworth, archaeological surveyor. While the rest of the team are frantically working away at their trenches and theories, he wanders around the landscape for a couple of days with maps in hand, bobbing his head up and down and occasionally lying down flat on the ground to get a better look at the "lumps and bumps", goes to the library to look at some ancient maps, and then returns to the others to tell them they've got it all wrong. Most of the time he's right.
  • John Gater, geophysicist, who heads the "geofizz" team. In early episodes, when asked about some splodge on the survey results he'd refuse to say more than "I don't know, it's an anomaly". These days, he doesn't hesitate to state "look at these responses, that must be a roman temple", and is frequently proven wrong when he does so, but it's much more fun that way.
  • Various other regulars, some of which have moved on over the years, such as Carenza Lewis, "Mick the Dig", and flamboyantly dressed historian Robin Bush.
  • Semi-regulars who are called in depending on their areas of expertise, like the deliciously named Guy de la Bédoyère who can date a Roman coin at twenty paces.
I don't know if it's just me, but at least I find it immensely uplifting and entertaining to watch a TV show full of people who can read and simultaneously translate original manuscripts in Old English and latin; people who can pick up a literally thumb-nail sized piece of broken pottery and almost instantly tell you what shape the original pot would have been and also that it was made in a particular town in Surrey around 1260 AD, by a left-handed potter in his late 40s; people who can look at a piece of a stone that was once part of a building and not only tell you which part, but also at what date, where the stone came from, and probably the name of the mason; bone specialists (osteoarchaeologists) who tend to get a slighty kinky gleam in their eyes whenever they find a skeleton (or more usually, pieces thereof), and how much they can tell from it; and "small finds" experts who can identify and date various small items based on changes in fashion and manufacturing techniques over the centuries.

What it all does, I think, is that it so well answers that question that everyone from schoolchildren to politicians ask on a regular basis: "but why should anyone want to learn that, and what good is that sort of research?" It shows that even if it can seem dreary to learn all the basics of a huge subject (that perhaps nobody else you know cares about), there may come a day when you are part of a group, and your deep knowledge about that particular subject can turn out to be really useful, even crucial. True, if everyone was an expert on coproliths, conversation might get pretty dull after a while. The cool things happen when you put people together who are experts in different (though adjacent) areas to solve a common problem. If you are really good at something, interesting tasks will find you, not the other way around.

Perhaps even more important, the show also demonstrates very clearly (and completely without being boring) the principles of scientific thinking and method, and why it is necessary. And mostly, this just happens as a side effect. Often, some impatient person will wonder why on earth they need to do things so carefully and in a specific order (this someone is often Tony Robinson who wants to see some action, or some happy amateur archaeologist who was there a century ago and came to some fairly premature conclusions). However, as the digging proceeds, it is often clear that it is because of the methodology that they can draw the strongest conclusions, and sometimes it forces them to throw away all previous theories. Or that in some cases, the normal methods just don't work, so you have to try another method, and another, or even improvise a new method, whatever works to solve the problem. It's what science is all about, turned into a whodunnit.

It also shows why a theory is only a theory until it has been thoroughly tested. No matter how clever and knowledgeable the person who proposed the theory, or how much the clues all seem to point in the same direction, the theory can still be wrong. If you can't provide some solid support for it, you must be honest and admit that for now, it's just a conjecture. An expert may get it right most of the time (much more often than you or me), but can still be spectacularly wrong sometimes, and testing is the only way to find out. Or as their buildings expert admitted in a recent episode from the 2008 series, he had been "slapped round the face by the wet haddock of reality". Makes me wish this was obligatory viewing in schools everywhere.

Watching the episodes in chronological order adds an extra dimension, not only because it follows the core team members over 15 years, which is fun in itself, but because it fast-forwards through some major advances in technology. When the first episode aired in 1994, the World Wide Web was quite new, and being able to display a map on a computer screen and draw some lines on it was considered high-tech. So was texture-mapped polygons - Doom was published in 1993 - and showing a primitive model of some old castle with the camera rotating around it was very flash indeed. Following the show, we get to see how computer modelling steadily improves, and GPS becomes not only a standard technique for geophysics, but so precise that you can measure key points with centimeter precision. Then bring in some elevation data from a national database, and suddenly you can show a rotating 3D-model of the entire landscape, with a superimposed map from the 16th century and a great little textured and shaded model of a Tudor mansion on top, and no-one bats an eyelid. A lot has happened in this decade-and- a-half.

Sadly, there is no "complete collection", not even a single entire series, to be found on DVD - if there was, I'd buy it immedately - but people out there have been recording it and digitizing it for the good of mankind. You probably know where to look.

Sunday, 1 February 2009

The times they are a-changin'

Recently I got a call from my dad, who was having some problems with his computer, along the lines of "there's something wrong with the damn internet again". Since I was the one who set it up for him, I don't mind fixing problems when they occur, but I find that the hardest thing with these debugging sessions over the phone is to get him to quote the exact messages he is seeing. It's kind of interesting, as if the words and concepts are so alien to him that he zones out after only a second, and is actually unable to read them aloud. A typical exchange goes like this: -So, dad, what does the error message say? -Oh, something about the Internet. -OK, but what does the text say, precisely? -I dunno, Microsoft and Internet something. -Dad, can you please tell me exactly what the text says? -I just told you, it says it can't find the Internet. -Where is the message, I mean, what program does it come from? -Well, dammit, it's right here, on the screen!

And so on.

This time, though, the problem turned out to be kind of funny. He really needed to log in to his online bank, and it was important, so although the symptoms sounded as if it was a problem with the remote site (something about an invalid certificate), I promised to take a closer look. Last time I was at their place, I made sure that remote desktop was enabled, and that their router would forward the right ports, so it would be easier to handle these situations. However, I still needed the IP of their router, so I had to spend some time voice-guiding him step by step through the router's web interface until he could quote me the address. Armed with this, it was no problem to log in. (I had the administrator password already.)

It turned out that he was absolutely right, the bank (and any other secure site he had tried) would complain about the certificate being outdated. But it was outdated in an unusual way: "this certificate will not be valid until ...". For a couple of seconds, I stared blankly at the screen, and then I moved the mouse down to the right corner and hovered over the clock widget. It said it was January 2003.

So the clock had reset at some point (I knew that the BIOS had had some hiccups lately), but for some reason the automatic clock synchronization didn't correct it. I checked, and it was enabled and it was pointing to a good NTP server. So I tried to force a new synchronization. The result: a message saying that the local time was so much off that it wouldn't even try. Well, thanks for nothing: in a situation where you really need to be saved by an external time source, it simply won't do it. There might be some good technical reason for that, but I can't think of one right now, so I think about punching Steve Ballmer instead. (Mmm...)

Anyhow, this just shows again how hard it is to foresee what kind of problems might occur with a setup once you leave it on its own for some time. No matter how well you've configured it so that nothing can possibly go wrong, something will eventually find a way to go wrong, and if you're particularly unlucky, it will be in such a way that the symptoms are quite far removed from the cause: in this case, a hardware glitch that reset the clock had no apparent effects, except that dad was suddenly not allowed to log on to his internet bank.

As long as this kind of thing can happen (and much too easily), how can we ever hope to give grandma a computer that "just works" and that won't suddenly barf up some weird messages on the screen and transform into an expensive brick?

Thursday, 29 January 2009

Spring break: the bad kind

Our car is just 5 years old, and has had no problems at all so far, but two weeks ago something weird suddenly happened. When you made a sharp turn, upwards of 90 degrees right or left, there was a sound as if a coil was being stretched, until it abrubtly went "goioinggg!" so loud that bystanders would dive for cover. Apart from this "cosmetic problem", nothing seemed to be obviously malfunctioning apart from the steering wheel pulling to the right. It didn't match any kind of car problem that I had heard about before, and nobody I talked to had any idea (apart from the usual helpful but wrong random guesses).

Yesterday, I got it back from the mechanic. The reason for the ruckus: a snapped suspension spring. (I didn't know this could happen.) Total cost: about $500 - they had to change on both sides. Sigh.

Monday, 26 January 2009

The final vinyl

As I wrote in a previous post, I did some extensive audio restoration of an old live recording by Brainbombs, that eventually got published as an LP by the small American punk label Richie Records, in a limited run of 500 copies. Well, in the end, one of those copies made its way back to me as a thanks for my efforts, and I'm very glad for it. It is actually quite a strange feeling, to hold in my hand a vinyl disc that holds the same recording that I mailed to the States on a couple of master CD:s over a year ago. The main thing, I think, is that this is so obviously a finished artefact, while mostly everything else that I create tends to be of a very fluid and nonphysical nature: digital representations that one can always pick up later and resume working on. This one, however, is very much "done". (Yes, you could remaster it and cut new vinyls, but the point is that this particular record isn't going anywhere. And no, burning a CD does not give you the same feeling.) In fact, it's probably the most finished thing I've ever been involved in making (to the despair of my PhD supervisor...).

Of course, the transfer to vinyl didn't make the sound better per se, but the surface noise adds even more "authenticity" to the experience.

Tuesday, 6 January 2009


While reading yet another book that presents one or more acronyms as an aid to remembering important points (this time, in "Pragmatic Unit Testing in C#"), I came up with my own acronym to express my thoughts about this. I call it Richard's CRAP rule of didactics:
  • Can't
  • Remember
  • Acronyms
  • Psomething... oh crap, where did I put that book...
My point is, that if you are able to remember not only what each letter stands for, exactly (is the I in ACID1 for Independence or Isolation...), but you can also give a detailed explanation of what each short bullet point really means (e.g., how is Atomicity different from Consistency and why are both needed), it means that you already have a very firm grasp of the subject. So while acronyms may be a useful device for not forgetting things once you understand them, they are fairly useless for the beginner.

However, it's worse than that; if they were only useless, they could simply be ignored. But the fact is that acronyms are quite often used precisely in texts for beginners, and more often than not they are used as the basis for the presentation of the material: first the list of bullet points is presented, and then a section or chapter is dedicated to each. I contend that this is exactly the wrong way to present any subject. It wastes pages (and the reader's time) on what becomes a mere shopping list, forgotten as soon as we move on to the next chapter, instead of using that space in a more constructive way to actually help the reader build an understanding of the subject to the point that he may invent his own acronyms if he needs them. (Finishing the chapter by suggesting such an acronym is quite OK.)

So here's a new year's promise: following this, I will never again (except for comical effect) use an acronym as the starting-off point for a text.

1) The ACID rule for databases: Atomicity, Consistency, Isolation, Durability. (Even I could not remember the last two verbatim without peeking, and I am quite familiar with database theory.)

Friday, 2 January 2009

...the devil in Helsinki

My goal was to process all my pictures taken this year before the year ended, and I almost made it, but not quite: yesterday I uploaded the last pictures from our little excursion to Finland in June. An old friend of mine who lives in Japan these days was going back to Sweden with his wife for the midsummer celebrations, and had booked their flight to make a stop in Helsinki for a couple of days. We decided to meet up with them there, so we got rooms at the same hotel, Helka (warmly recommended), and brought our car on the ferry from Stockholm. That way we could both walk around Helsinki on our own for a day, and after our friends showed up, we made a day trip by car to see some sights outside the city, in particular Hvitträsk, west of Helsinki, and the sleepy town of Borgå to the east, with its old wooden buildings. The next day we said our goodbyes and drove westwards to spend midsummer on Åland, stopping in Åbo on the way to do some more sightseeing.

This was a great opportunity for us to do really touristy things in Finland (as the pictures show), and we had a lovely time, with sights ranging from the latest in Finnish furniture design in Helsinki, to the over 700 years old cathedrals of Borgå and Åbo.