Hex Code

Well I suppose I’m a programmer now. Of all things.

It’s not what I expected, to be honest. I still associate the word with men in lab coats and bow ties in front of banks of flickering lights, doing arcane things at rattly teleprinter terminals. Something to do with rockets probably. Robots even. And punched paper tape!

Hippo

Punched paper tape was amazing, I used to collect discarded lengths of it from offices where my mother worked as a temp. Its perforated patterns are the perfect metaphor for the state of computing when I was a child. Pretty, delicate, clearly meaningful and yet profoundly mysterious.

These days? It’s writing really. You’re using language, a kind of language, to convey your intended meaning. Like much writing it’s part creativity, part drudgery and repetition. Long-separated senses of the word “hack” meet by surprise in a foreign city.

And like their natural counterparts, programming languages are a pretty diverse bunch. But you’ll hardly find two more different than the ones I just certified in – SQL and PHP. They’re like Choctaw and Chinese. Or more helpfully, Latin and English. One is (relatively) ancient, dusty and rule-bound, the other young and a bit anarchic.

Strangely though, it’s the old one that was actually designed to be English-like. And in the time of the lab coats I guess it seemed like it. A SQL command is called a “statement”, and is constructed much like a sentence:

Select roses, tulips from basket join bouquet where colour = "red"

Sounds almost like the real thing, doesn’t it? But…

Select camel, serendipity from D547 join moonslip where fandango = "buttocks"

…is equally meaningful. The resemblance to human language is superficial for a reason: In SQL there is only a handful of verbs, representing the very limited set of things you can do with items in a database. Its ‘nouns’ are little more than arbitrary labels. Real language is almost immeasurably more complex than that.

The thing that makes SQL seem completely unnatural though is its obsession with data types. These are important up to a point of course. You need to know what kind of data you’re dealing with, whether it’s numbers, “string” (which is what programmers like to call written words), dates and times, or more exotic stuff. You can’t add a word to a number or multiply a date.

But in SQL these break down into seemingly endless subtypes: For a number you need to know what the base is, whether it has a decimal point, if it’s positive or negative. With words it matters what the language is so that the right characters are used, plus you need to know what alphabetical order is for those characters, whether case is significant and so on. Dates and times are available in a mind-bending range of formats, depending on, say, whether you’re more interested in events since 1,000 AD or 1970.

Where it gets ludicrous is that there are still further subdivisions, into units of different size. (My favourite is called the Binary Large Object – or for short, BLOB.) The idea was to set aside only as much space as your data is going to need. If you have a column wide enough for six-figure sums and then enter numbers in the hundreds, you’re effectively saving blank decimal places to your hard disk. In the ’70s, disks were expensive. There was no room for empty space.

Compared to this, PHP seems like it was invented by hippoes. (I meant to say hippies there but I’m going to leave the typo in.) It’s just so… relaxed, skipping lightly over the very things that make SQL tedious. It seems to just guess what your data type ought to be. “You’re trying to add a number and a letter together? No problem, let’s see what happens.”

What makes it even more like human language though is the fact that it’s “Object Oriented”. This is a big idea so I’ll leave the details for another post, but suffice it to say that like real nouns, an object in OO programming is meant to represent something in the world. As such it comes with its associated “verbs” (known as methods) that represent the actions characteristic of that object. So the things that exist in your program have hidden powers that you can call upon if you know the right words. Cool.

Perhaps the best comparison then is not with different natural languages, but with different specialised jargon. Moving from SQL to PHP feels a lot like leaving contract law to take up alchemy.

Who Deserves To Die?

One of the most indefensible consequences of the property orgy and subsequent bailout deal is that innocent people will be made to pay with their lives. It’s one example among very many, but from today people in Roscommon who are severely injured are going to be sent to Galway.

Those of us who live in Galway know that emergency services here are already overwhelmed. We also know that we have some of the worst traffic congestion in the country.

Let’s state this in as simple a way as possible, so that even our elected representatives can understand it. Because of the closure of Roscommon accident and emergency, someone is going to die.

But it will not be a member of a bank’s board of directors, to take a random example. They have an alternative. While all this is happening, a commercial organisation calling itself Beacon Hospitals thinks it timely to advertise that they offer an emergency service. Their slogan?

“Because You Deserve Better.”

Click On My Face

This is a artistic steganography try. It talks...
There could be a link encoded in this image. There isn't, but there could be.

Yesterday I was discussing QR codes, and the possibility of turning the actual text in magazines or on posters into links. I see no reason why in the very near future you couldn’t go to a Web page, video or other online resource simply by pointing a phone at a printed URL. These methods could help revive the flagging newspaper and magazine industries, by introducing a much greater integration between the printed page and the Internet. For example you could easily share a magazine article with Facebook friends.

An idea that I can see supplanting even this though is a form of steganography – that is, encoding links and other data into pictures, in such a way that they can be read by machine without being visible to humans. Actually this is already used for anti-forgery systems; Adobe Photoshop for example will refuse to handle scans of Euro notes because it recognizes a pattern hidden in the design. The same method could turn photographs into clickable links when you look at them through your phone.

And print designers will absolutely love this. Not only do they not require blocky codes or funny fonts, they can make tired elements like www and .com finally vanish from their pages. So these I think will be with us pretty soon. Until they’re eventually replaced by RFID ink.

Ink With Links

A Japanese advertising poster containing QR codes
Adverts with links let you buy on the spot.

When I posted yesterday about QR codes, those little symbols used to put Web links on real-world objects, reader Azijn made this thought-provoking comment:

I find QR codes a bit weird. Why not have an app that can simply recognize a certain default font in which advertisers will agree to publish their URLs? Humans and phones alike can recognize that!

Indeed, I can find no such app. How come? Azijn’s idea would surely work.

But then you have to remember that most design actually happens by accident. QR codes are prevalent for this purpose mainly because they’ve been around long enough to catch on. They were invented by Toyota for labelling components and it was in Japan that they were first used on phones. But that doesn’t mean of course that they’re the best solution.

QR codes did have a couple of advantages. They were designed expressly to be read by machine and have built-in error correction, so they were easier for simple devices to process. But now that phones are very powerful computers they should have little trouble handling text recognition – I doubt if there’s even any need for special fonts¹.

I can think of one way to speed things up though: A typographical convention to indicate where a website address begins and ends, such as putting it between two easily recognised symbols, so that the phone doesn’t need to scan whole pages. Example:

►http://i.doubt.it◄

Any such text will be highlighted on your phone’s screen, showing you that it’s clickable.

Can I get a patent on that?

  1. There have been fonts designed to be easily read by machine since at least the 60s, for example the hardcore OCR-A, the more friendly OCR-B, or the space-age classic Westminster – which I had always thought belonged to NASA or IBM or some such but turns out to have been created by a British bank. These days though Optical Character Recognition software is so good that they are no longer really necessary, though obviously plainer, less ornate fonts are likely to get better results.

Coke Ads, Life

The Two Infallible Powers - The Pope Bovril
God I love this mad old advert

Imagine that. The 125th anniversary of Coca Cola. We tend to think of that brand as symbolic of the modern world. It’s strange to remember that it’s a weird holdout from the Victorian era, like Bovril or Beecham‘s Powders. Perhaps this means it actually is an excellent product. We’ll never really know – how can you possibly separate the actual drink from its image and its history?

Hmm. Maybe there is a way. Apparently Osama bin Laden and his cohorts were fond of the stuff. If someone so vehemently opposed to everything the product is associated with still enjoys it, then surely the only explanation is that it is an objectively good beverage.

Well OK, it might also mean that Bin Laden was deeply conflicted and/or hypocritical. But still, you can’t help feeling that Coca Cola missed an opportunity for the most amazing celebrity endorsement ever.

The Cookie Monster

Cookie CartoonLook at this, this is cool! The classic arcade game Defender, but miniaturised to the 16-pixel square of the page’s favicon (the little logo that appears in your browser’s address bar and bookmarks). You can actually play it.

Of course, you may fairly ask what is the point of playing an old video game in a space about one ninth the size of a postage stamp. But I don’t care, it’s a wonderfully clever bit of Web programming.

Speaking of which, do cookies worry you? The browser ones I mean. Perhaps they should. They were innocent things to start with, just a simple file that a website you visit is allowed to leave on your computer. Yet that can be extremely useful, allowing sites to recognise you when you visit again and log you in automatically.

But then, they can be abused… Suppose you visit a site that has an advert on it. The ad will normally be served from a whole other computer, belonging to the advertising service. And that computer gets to leave a cookie too.

Think what happens next – you go to a lot of sites, you see a lot of ads. But many of these will actually come from the same source, and when that computer reads the cookies it put on your computer earlier, it has a record of other places you’ve been.

A picture can then be built up of your movements across the web, and even used to serve adverts tailored to your particular interests. Or predilections. You might see that as a boon and a convenience, but others may find it uncomfortably intrusive. Especially if they share a computer with family or colleagues.

I’m in two minds about this. After all nothing you do on the Web is really private anyway, so making a fuss about cookies is like complaining that the gorilla on your chest has dandruff. And yet I don’t much care to look at adverts in the first place, so I like the idea of them watching me back even less. I routinely block all cookies, making exceptions only for the sites I visit regularly. This is easy enough with Firefox, using an add-on like Cookie Monster. Call me paranoid, but I’ll get upset if you do.

And it seems the European Commission agrees with me. An e-privacy directive will mandate that sites will only be able to track you with your explicit permission. Is it going to work though? Some argue it will make browsing irritating, with sites continuously popping up messages saying things like “Can I track you please? There are many benefits!” But in the competitive world of the Web, I doubt that users will put up with such nonsense.

So I think it will work. The real danger perhaps is that the ban will give people an illusion of privacy. It means no such thing. If you want real privacy on the Internet, use a proxy.