/tech home / projects / personal 'blog / about


ARCHIVE: Is XML the best we can come up with?

Mon. Jun 6th 2005, 10:05pm:

It looks like these days, everyone loves XML, after all it is a subset of SGML and has some semantic significance. From every B2B vendor's export-report feature to Microsoft's decision to use XML as the primary file format in future versions of Office, XML is here to stay. Kinda like the VCRs, easy to use, easy to setup, and almost universal - who wouldn't use XML!

I guess people like me; I hated rewinding the video cassettes and I hate repetitive typing. I don't mind typing, in fact I love typing more than writing and on some occasions, speaking, but I absolutely hate typing one start tag after another. Obviously, I don't create XML files by hand and output them from scripts, kinda like my RSS and Atom feeds. However, every time I have to implement a system in a language that doesn't provide huge XML-parsing libraries, I wonder, is this really the best way to send and receive small bits of information?

Thankfully, I'm not the only one who thinks XML sucks. Here's another guy who realizes Where XML goes astray. I have a simple philosophy when it comes to programming, "I should not be required to type 2x number of keys when x will suffice." Instead of start tags like <name> and end tags like </name> in XML, why not just use <name> for start and </> for end? If it's to avoid errors in end tags, then just make it optional, after all, start and end tags like "{" and "}" have worked in most programming languages for decades without anyone complaining about them.

Good to know that there is choice for people like me who don't like XML and think it's a pretty retarded way of exchanging data. Here is a list of XML Alternatives, one of which is my personal favorite, having already used it for dynamic programming in Ajax, instead of XML: JSON. I use JSON-PHP for now and eventually want to switch to whatever works best on Ruby On Rails (RoR).

The great thing about JSON-PHP is that if I want to send a list of 10 values from my PHP function on the server to a JavaScript callback function on the client-end, I just encode it using JSON->encode(array(10-values)) function and send it. The JavaScript callback function just runs eval("var retAjax = " + result); and instantly I have an array in JavaScript called retAjax[0-9] that has the same 10 values that my PHP function sent. I'm thinking of putting up a simple library of PHP/JS functions that will allow anyone to use Ajax+JSON on their sites. I currently use Sajax to make my life easy and have created a few functions to send/receive data using JSON-PHP. Maybe this 'blog needs a 'downloads' section.