OK, I Give Up. You Can Have My Privacy.

Any day now, I expect Google to release their latest product: Google Toilet Paper™.

It will be delivered to your doorstep for free, the production costs covered by targeted ads printed on the paper in biodegradable ink. It will be softer and nicer than any competing product (except Apple’s, but that’s quite expensive and only works in Apple Bathroom™s), and it will have several unique features which I’m not smart enough to anticipate but which will surely revolutionise the toilet paper industry overnight.

Inside every roll, there will be an RFID chip which can be read by the RFID reader in the next generation of Android phones. There will also be a simple rotation counter connected to the chip, so that the roll knows how often you use paper when you visit the toilet, and how much paper you use each time. All this information will be automatically uploaded to Google, the next time you sync your gmail account with your phone. By matching the pattern of your toilet visits to the e-mails and search queries of people with similar patterns, Google will then have a pretty good idea of any bowel-related afflictions you may have, often long before you do.

RIP Benoit Mandelbrot

Benoit Mandelbrot died a few days ago, at the age of 85. He is best known for discovering and popularizing the concept of fractals, in particular the Mandelbrot set and its close relative the Julia set.

In doing so, Mandelbrot gave the world much more than just a way to create pretty pictures and psychedelic animations. The realisation that such a literally infinite amount of complexity, not to mention beauty, could be created with a formula which you can write on the back of your hand, influenced thinkers in just about every field from philosophy to economics and from physics to biology.

As a little tribute to the man, if you are a programmer, I hereby encourage you to implement his famous fractal in your favourite programming language. It’s really simple; in many programming environments, opening a canvas to draw the pixels onto will be more work than actually calculating the fractal.

Here is how it goes: first, you need to pick a portion of the complex plane to visualize. To get the famous, fully zoomed-out version of the Mandelbrot, a good starting point would be from -2.5 + 1.5i to 1.5 – 1.5i.

Not comfortable with complex numbers? No problem; for our current purpose, all you need to know is that a complex number is a point in a two-dimensional space; in this case, the space from (x = -2.5, y = 1.5) to (x = 1.5, y = -1.5). And that there are certain rules for doing basic arithmetic on them, such as:

  • Addition: (x1, y1) + (x2, y2) = (x1 + x2, y1 + y2)
  • Multiplication: (x1, y1) (x2, y2) = (x1 x2 – y1 y2, x2 y1 + x1 y2)

Now, on to the Mandelbrot fractal. Formally, the Mandelbrot set is a set of points; any point is either inside the set or outside it. To determine whether a certain point p is inside the set, you calculate:

z0 = 0

zn+1 = zn2 + p

repeatedly. If this sequence goes to infinity for large n, the number is outside of the set; otherwise it is inside the set. Draw all the points which are inside the set in one color, and all the points which are outside the set in another, and you get the famous Mandelbrot fractal!

From a programmer’s point of view, there are two obvious questions here: a) can you please be a bit more specific about “goes to infinity for large n”, and b) most of the Mandelbrot pictures I’ve seen have much more than two colours!

The answer to both questions is: what you normally do is, you continue iterating until the distance between z and (0, 0) exceeds 2, and you colour the pixel based on how many iterations it took to get there. If, after a certain arbitrary number of iterations, you still haven’t reached 2, then you assume that the pixel is inside the set; the traditional colour for those pixels is black.

Silly Workaround for Android 2.2 Not Importing vCard Files via Bluetooth

I bought myself a new phone yesterday: an HTC Desire HD, running Android 2.2. On the whole, I’m extremely happy with it — especially since my previous phone was an LG Windows Mobile piece of junk which didn’t really deserve the name ‘smartphone’. There are a few quibbles, however.

One of them is this: I had a lot of contacts stored in the phone memory of the LG rather than on the SIMM card, so naturally I wanted to transfer them to its successor, preferably via Bluetooth. The HTC actually offered that option during the initial setup, but only for a limited number of models, mine not included.

But, fear not: the LG offered the option to transmit contacts to another phone via Bluetooth. One at a time, unfortunately, but hey — it didn’t take that long, and it gave me the opportunity to clean out some contacts. After perhaps five minutes of diligent Bluetoothing, all the contacts I still cared about seemed to have been transfered, with the Android phone happily saying something along the lines of “transfer received successfully!” for each one.

And after that, they turned out to have disappeared.

Upgraded to Ubuntu 10.10

The upgrade to Ubuntu 10.10, “Maverick Meerkat”, went smoothly enough. Except for one thing: Grub, as always. For some reason, Grub really hates me: for the last three Ubuntu upgrades, every time when I rebooted after the installation, it failed to boot. This despite the fact that I have a very straightforward setup: no dual-boot or anything, just a single Ubuntu installation on the machine. The error message this time was something along the lines of “unknown function”; I didn’t write it down exactly.

Martin Starts Link-blogging

When I started this blog, it was with the intention to write a post only when I had something interesting to say. Well, given my deplorably low posting frequency over the past year, I guess we have found out how interesting a person I really am.

So I am going to, every now and then, write a blog post just to share some links I found on the web recently which happened to catch my eye.

About Chess and Nuclear Reactors: The Case for Exception Handling

The world of software development has more than its fair share of topics where people tend to have long religious discussions about the “correct” way to do something. I think this is partly because the field for some reason attracts the kind of person who enjoys a nice bout of verbal fisticuffs, and partly because we spend a lot of time dealing with very abstract topics where the pros and cons of a given choice have more to do with differing philosophies than with objective facts.

One classic topic for this kind of discussion, which came up recently at work, is the use of exceptions for error handling. Every modern programming language offers an exception mechanism for this purpose, and presumably it is there to be used. However, ever since they were first introduced, there has been a large and vocal subset of the community arguing that exceptions do more harm than good and you’ll be writing better code if you just use good old return values to report whether a method succeeded.

One representative example comes from Joel Spolsky, one of my favorite authors. Another oft-quoted article making the same arguments is found in the “Frequently Questioned Answers” by Yossi Kreinin. They both make the same basic points: exceptions do not reduce complexity but merely hide it, and when complexity is hidden people tend to forget about it.

These arguments have merit, but I still feel that (when properly used) exception handling delivers enough value to be worth the cost. So I am going to be arguing for the status quo here, for a change. Executive summary: the dangers of exceptions are real, but code readability trumps almost everything.


This is a blog post about something which took place six months ago, so it could be considered somewhat belated. On the other hand, that gives me the opportunity to give the full story in one go, rather than just posting “well, I had the operation two hours ago and they didn’t actually blow up my eyeball, so I guess it could have been worse, but I’m not really supposed to be staring at a computer screen just now and anyway I am doped up on painkillers so I’m leaving now, okthxbye.”

The Betrayal of the Spirit

I don’t normally like to do “link blogging” — I’d rather post nothing at all for several months (which frequently happens) than just copy someone else’s work. But I’ll make an exception for this XKCD strip. I think it actually brought a tear to my eye.

Scripting Excel: Can It Really Be This Horrible?

OK, I have managed to avoid this for a long time, but I guess it was inevitable: here comes Martin’s cheap, nonconstructively sarcastic I-hate-Microsoft post.

So I was visiting my parents this week-end, and my Dad asked me to help him with a little macro job on an Excel spreadsheet. It sounded simple enough. However, I had forgotten just how astonishingly horrible Visual Basic For Applications, the sorry excuse for a programming language built into Excel (and the other Office applications), can be.

As far as I remember, the last time I did anything with VBA was probably somewhere in the late nineties. Even by the standards of back then, VBA is a really shitty programming language. By the standards of 2009, it’s spectacularly bad. The only explanation I can think of is that somewhere high up in Microsoft Strategic Command, somebody decided to spend a lot of effort on making it as useless and infuriating as possible, while still keeping it just barely functional enough to be able to do the things you want to do with it, if you’re willing to go through a lot of pain. God only knows why they made that decision, but surely a language as bad as this cannot be created by accident.

Paying With Bits

In the course of a friendly discussion with Dirk-Jan, I’ve been reading up on the miracles of digital cash.

And by digital cash, I do not mean lame stuff like Paypal, which is basically just an ordinary bank account to which you can send transfer orders. No, what I’m interested in is the real heavy stuff, whereby you have a digital wallet full of cryptographic “coins” which can be transfered from one party to another, without a single central entity keeping track of the contents of your wallet. Ideally, you want to be able to transfer such coins even off-line, without the central entity needing to be involved with every individual transfer.

There are a couple of basic problems with the idea of using bits as money, which any “crypto cash” system will need to find solutions for.