Grieve (grieve) wrote,
Grieve
grieve

XML

I've always complained about XML especially as a network protocol. Now at work I am having to actually use it, and it is every bit as bad as I feared. I think XML is a bad idea, and for network protocols it is even worse. Below I list the commonly listed benefits of XML, and debunk them in relation to protocols:

  1. Human readable - So. The protocol is for two machines to communicate not two humans. People often claim it is easer to debug if the format is human readable. In reality when you are debugging a protocol you step through your parsing code in the debugger.

  2. You can use off the shelf parsers - Yes, I could, but have you seen the size of those things. I can write a binary parser in the time it takes me to understand an XML parser, and the parsers themselves are not standardize. Each one has its own quirks and behaviors, even ignoring SAX vs DOM.

  3. It is a Standard - Yes XML is a standard. I agree. But what it standardizes is the format of the protocol. Not the protocol itself. Your code will still have to understand what the tags mean, and that means an avalanche of string processing is about to descend on you even after you parse the XML. And we all know how fast that is. Additionally XML does not provide any kind of mechanism for a message header if you are trying to use it as a protocol. This makes the socket layer code extremely complex. Almost all XML based protocols use a homemade header of some-sort. Not very standard now. Additionally most XML I have seen is not truly valid XML as it has no DTD and no XML header (not to be confused with a protocol header). It is mostly XML like.

  4. XML is what "The Web" uses. - No "The Web" uses http. Not my favorite protocol since it uses fairly complex variable length headers, but at least it is truly standard.

  5. Binary is too complicated - Not really. In fact if you really understand what is going on in the computer you will realize it is all binary even XML. What people perceive as complex in binary is typically datatype size and Endianess. XML doesn't avoid this. It defines it in the XML specification. Any worthwile protocol will also define these, and any decent programmer can understand both concepts, if they don't already, in about 5 minutes time.

  6. XML is flexible - So is binary. Hell binary is so flexible you can write XML in it. If you cannot design your protocol to be extensible without XML, you need to think about the problem more.

Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 6 comments