Caffeine Peter Colijn
(RSS)

January 16, 2008 (link)
Treatise: Why I hate XML

In my line of work, I unfortunately sometimes encounter people who like XML. Upon hearing that I despise XML with a passion that burns hotter than the heat of two suns, the brave ones sometimes ask me why. So I don't keep repeating myself, I figured I'd write up a little XML bash-fest here so that I can just point them at a URL.

There are many reasons to hate XML. I'll go through the main reasons I hate XML and common responses.

  1. It's too verbose. Consider this uncov post, where we discover that query results from Amazon's SimpleDB have a transmission overhead of 1755%. No, you read that right, there isn't supposed to be a decimal in there. Oh, but you can gzip it, they cry. And there's that weird binary form of XML that nobody uses! gzipping may help, but eats CPU, and even the weird binary XML format still has significant transmission overhead.
  2. It's too complicated. The spec for XML is huge. There are of course plenty of complicated things that I don't hate, at least not to the extent I hate XML, like C++, so this in itself does not immediately qualify XML for my hatred. The big problem though is that XML is complicated and nobody understands that. They made it look kind of simple, so people think it's really simple. And then instead of using a decent XML library, they write their own shitty regex monstrosities, filling the world with crappy and malformed XML, and creating lovely security bugs like cross-site scripting vulnerabilities in the process.
  3. Parsing it is a pain in the ass. Even if you use a decent XML library, it's still a pain. Using DOM eats up tons of memory: suppose you have a 1M XML file and you want the DOM tree - you will probably use at least 5M. As a tangent this is why it's often faster to set foo.innerHTML = html in JavaScript than to manipulate DOM properties, at least for relatively small snippets of HTML; most browsers lazily instantiate the DOM tree. And of course SAX parsing may be lighter on memory but is generally much more complicated, especially in non-functional languages.

Do I think XML has absolutely no uses? Not strictly. For layout, like on web pages, it's not too bad. The escaping is still a pain in the ass, but any language you use will need some form of escaping.

What do I think is a good alternative to XML? These days, I favor JSON. It's way more compact, still human-readable, and easier to parse. Plus JSON documents inherently represent a property tree, which to anyone familiar with object-oriented programming is very intuitive.

Completely unrelated: CrapBook Air

I'm not falling for it this time:

  • 100% aluminum case = shitty wifi reception
  • Non-replaceable battery + "5 hours" battery life = at most 2.5 hours of real battery life and no option to carry a spare
  • No 3G = useless as a truly "wireless machine". It has bluetooth but you can't even pair an iPhone with bluetooth to get your shitty EDGE connection.
  • 1.8GHz Core 2 Duo = burning balls

Though I do have to admit, I have geek lust for the 64GB SSD. Having had 4 hard disks die on me this year, I can appreciate the value of an SSD.

January 20, 2008 (link)

iPod Touch

So after Apple de-crippled the iPod Touch last week, I decided to take the plunge and get one. I can play with browser and touch apps and so on without needing to pay for a crappy AT&T contract. They gave me $20 off at the store so I could pay for the de-crippling.

I have to admit, it is pretty cool. The mail client works great with GMail IMAP, and it's pretty remarkable to have such a small, thin device that supports wifi and email and watching movies. Of course, there are some things I find bizarre and strangely un-Apple:

  • The software "upgrade" process was really bad. In iTunes, I first had to agree to upgrade the software, agree to a license, and then it installed. I thought I was done, but that was just the upgrade from 1.1.1 to 1.1.3. I still had to go through another process to pay $20 and get the new apps.
  • After I actually went through the second $20 de-cripple process, iTunes displayed the exact same page it showed before, so I didn't even know if it had worked. Fortunately I had read reports online about people who were similarly confused and accidentally paid twice, so I unplugged the iPod at that point and sure enough it had the new apps.
  • On the actual iPod, if you play a video podcast from "Music", it only plays the sound, but if you play it from "Videos" it plays video and sound. This seems like an unnecessarily confusing distinction.
  • Before syncing, in iTunes I went through and painstakingly added album art for all my music from Amazon, manually, since iTunes is really awful at finding it automatically. But none of that album art I set manually was synced. I don't know whether this is intentional or just a bug.
  • I hadn't used iTunes much before getting this thing, and it turns out to be ridiculously slow. Things like selecting a bunch of songs, editing the properties and setting the "Genre" tag would cause the beach ball to show up. Seriously, WTF?
  • Of course (and I knew this when buying the thing) it is the most locked-down proprietary thing I have ever owned. It works well enough, but the most I can do with it in Linux is charge it, which sucks. If you downgrade to the 1.1.1 firmware and jailbreak it, you can apparently copy stuff to it in Linux over wifi using fuse and ssfs. What's ironic there is that the Linux hack adds a feature (wifi sync) that even official iTunes doesn't offer.

Still, the silky smooth animations and cute UI are winning me over. It is really slick. Reading email and surfing on such a tiny device feels very Star Trek-esque. Now if only we could get transporters, we'd be set.

Back: December 2007 Next: February 2008

email: caffeine@colijn.ca