Saturday, March 31, 2007

XML sucks!

First rant of my new blog!

Setup:

I'm migrating my iTunes install off of my windows box onto my shiny new mac-mini.

iTunes has the ability to export my podcast list into OPML.

Great right?!?!?

Nothing could be easier thanks to the ultra-portable XML standard that obliterates the idea of cryptic, closed file formats.

Wrong!

When I import the file into the mac-mini I get a wonderfully expressive 'unknown error (-50)' message.

Long story short, after trying to convert line formats using dos/unix/mac format, and a couple of other voodoo things I know to check for because I've had the pleasure of dealing with several XML parsers I finally end up doing the following:

I exported out a simple OPML playlist from the mac-mini iTunes.

I cut and pasted all of the 'meat' from the winows OPML file.

I saved and re-imported into iTunes and voila, it worked.

Now I know that it has to be a line-end-format issue because I actually chopped/pasted the windows OPML file to the exact text of the mac-mini OPML file and kept getting the same error. Since, I haven't bothered to grab a hex-editor I don't know exactly what the problem is but I'm sure of one thing: XML files aren't supposed to care about end of line formating of crap outside of the tags!!!

This in a nutshell is the problem with this fucked up standard. It isn't the idea of the standard itself that is the problem, the problem is that almost every parser 'cheats' (usually because of re-use of existing text-file library reasons) when implementing it (by relying on things like 'end of line' when grabbing text from the file).

XML is the epitome of a top-down standard that looks great on paper but is a nightmare to use in the 'real' world because programmers are basically lazy, and writting a 'correct' parser is really pretty darn hard, and I can write something in a short amount of time that will work 'good enough' to solve the larger technical problem I'm wanting to solve. Meaning that at the end of the day XML is just a touch too 'brittle' to be the true universal standard it should have been.

Maybe I shouldn't be bitching, because the OPML file (broken as it was) was much more open than some binary file format. I was able to solve my import/export issue, and there is no doubt that any attempt at open-ness (even if it is messy and harder to deal with than it should be) is way way better than the closed world of binary file formats.

Still it sucks and I for one refuse to accept it any longer.

XML might have been a good first step on the right path, but a better bottom-up standard such as JSON is going to win eventually just on ease of use. At least that is where my money is at the moment. It isn't as flexible or as rich as XML, but really I'm thinking that might just end up being a plus.

So for now I say to hell with XML! Long Live JSON!

No comments: