Why I f**king hate XML
Author
Discussion

TheExcession

Original Poster:

11,669 posts

280 months

Tuesday 24th October 2006
quotequote all
Consider this.....

Part of my test tool suite includes a function that can read and write to TCP sockets. I often use it for testing SOAP and HTML interractions. It's scriptable so I can send a message to an HTTP Server along the lines of a get or a post. Upon receiving a reply I can also detect the content-length, read to the end of this and I end up with a string in memory that contains the response.

I can then perform some Extract operations that will 'sub-string' the received data, extract a value and assign it to a variable that I can use later in my test script.

As part of my Extract command I specify the start and end point in the received data that I want to extract from. Not only can I do this with number referencing the exact position in the string that I want to extract some information, but I can also do it by specifiying 'tokens'.

Thus, if I receive 'Have a nice day' I can set token1 = 'Have a' and token2 to ' day' and I'll get 'nice' as my extracted value.

Beyon that, and this is where I thought I was being really cool, I can specify a skip count for each token.

Thus, if I receive 'Have a nice day, in fact have a really nice day' I can set token1 = 'Have a' and token2 to ' day', indicate that the tokens should be skipped once and I'll get 'really nice' as my extracted value. Really nice I'm sure you'll agree...


Now, as part of our testing we are trying to drive VLC via its very own HTTP interface. No problem until you realise that to start a track playing you have to query the play list and determine a numeric ID of the track you want to play.

No, problem my code will send the requisite 'GET /requests/playlist.xml HTTP/1.1'
and I receive a lovely XML formatted response showing all the items in the play list.

The shit of it is though that the ID number that you need to send in another GET request to start the track playing comes before the name of the track....

I've removed the angle brackets to make it readable, but it goes like this...


leaf id="4" uri="E:musicADFRafi RevengeADF 10 Operation Eagle Lie.mp3" name="Operation Eagle Lie"

leaf id="5" uri="E:musicADFRafi RevengeADF 01 Naxalite.mp3" name="Naxalite"

So what's the problem? Well my script knows the name of the track it wants to start... e.g. 'Naxalite' but by the time I've found my token 'Naxalite' I've alread ready read beyond the leaf id of 5

Now I have to code up some rewind function into my script language so that I can extract from behind my match tokens.

XML sucks, it's ing shit, I've never yet seen any thing done in xml that couldn't be better achieved another way. It's lame, I'm fuming and instead of posting here I should be writing code.

Just needed to get that off my chest.

best
Ex


Edited by TheExcession on Tuesday 24th October 21:00

m12_nathan

5,138 posts

289 months

Tuesday 24th October 2006
quotequote all
What are you writing it in?

TheExcession

Original Poster:

11,669 posts

280 months

Tuesday 24th October 2006
quotequote all
m12_nathan said:
What are you writing it in?

The testing application is written in Microsoft VJ++ so it's maintenance of code that is nearly 8 years old

But more importantly, it's more a case of the fact that I designed a script language and a parser for this language. The java code reads and interepts a text based script file and turns this into a whole bunch of Java code that is run by my Application to exercise the System Under Test, in this case VLC. It'd a big Application, approximating about 75,000 lines of code. There's a lot more in there than I can explain.

There's no easy way round it, VJ++ has no native support for XML and even if it did I'd still have to code all that into my application, it's a bollox, all I want to do is read and write to a TCP socket, which my script language will handle very very well.

What has pissed me off is the simple fact that many people get their Apps to generate an XML document with little or no thought to how that doument is to be interpretted.

The simple fact that often you can't read an XML doument and extract the information you want in one pass, i.e. I should never have to rewind a file pointer just leaves me fuming.

I've had this previously with so many 3rd party Applications that supposedly generate these wonderful XML documents. I've lost count of the number of times I've had to write a transcoder to insert information into the XML stream so that a 'sensible' program can actually do some work with it without having to back track to find specific bits of information.

Certainly I could load this stream into an XML parser that would create lots of little nodes in a pretty tree structure and then I could just ask the structure to tell me what the leaf id for a specific name is.

But why? Why should I need to generate a whole complex structure just to get a simple piece of information that I should be able to obtain in a single pass.

I'm telling you, people that really understand what this is about have been doing it with SNMP for years. Then along come a bunch of muppets with XML, with their 'ohhhh but it's human readable...' reason for a half baked, ill though out mechanism, that three times out of ten IMO is pretty much useless.

Maybe I'm being too hard on XML. Maybe it's just a poor implementatiion and I should complain to the authors of VLC, but if this had been done using a MIB and SNMP my problems would never have arisen. You just couldn't present information in this manner and screw it up so royally.

Anyway... cheers for your interest... Think I'll nip orf to buy a bottle of plonk...

best
Ex


off_again

13,917 posts

264 months

Tuesday 24th October 2006
quotequote all
I work for a network security company and the entire configuration set for it is entirely XML.....

The blokes who write the code litterally talk in a different language... hehe

Mind you, the flexibility that it provides is stunning. Want to change display? Simple. Want to filter it in a different way? Simple. Its a great system, but boy its flipping awkward to use....

m12_nathan

5,138 posts

289 months

Tuesday 24th October 2006
quotequote all
I think it is because with modern languages XML is so easy to parse and deserialise into objects that no one gives a second thought to someone trying to use it from an older language. Good luck with it.

roadsweeper

3,789 posts

304 months

Tuesday 24th October 2006
quotequote all
m12_nathan said:
I think it is because with modern languages XML is so easy to parse and deserialise into objects that no one gives a second thought to someone trying to use it from an older language. Good luck with it.
yes

XML is a fantastic format, but I can imagine it's a pain in the arse to custom parse.

dern

14,055 posts

309 months

Tuesday 24th October 2006
quotequote all
As an alternative (and it's a bit of a shag but very interesting) is to write your own custom language effectively that only contains the information you need. Do a search on ANTLR for a really good laxer/parser. I used it for a project at work and it's interesting to play with and very neat.

Regards,

Mark

Don

28,378 posts

314 months

Tuesday 24th October 2006
quotequote all
Interesting.

I have always been suspicious of XML. Often - its glorified CSV the way its mostly used. And if not? Its a sodding hierarchical data structure - and I thought we'd got rid of those years ago when we got ourselves relational databases...

For what its worth? I hate ing XML too. Unfortunately you and I are shit out of luck as the world thinks its ing brilliant. There we go. We'll code up stuff that uses it when we need to and mutter darkly under our breath same as always...

Mind you. When SQL first arrived and I compared it to a native C access relational database competitor I found it severely wanting. These days I'm a guru. About a bazillion horsepower and a whole lot of convenience changed my mind. Maybe XML will finally convince me...one day...

victormeldrew

8,293 posts

307 months

Tuesday 24th October 2006
quotequote all
I've never been a great fan of relational databases (and I've used them since before Oracle was a glint in Rdb/VMS's eye!); XML is great for me because it is very similar to the multivalue databases I know and love - variable length, tag delimited, hierarchical data. Perfick!

Don said:
Its a sodding hierarchical data structure - and I thought we'd got rid of those years ago when we got ourselves relational databases...
You thought wrong Don!

Edited by victormeldrew on Tuesday 24th October 23:39

Spyke

175 posts

268 months

Tuesday 24th October 2006
quotequote all
Count me in as an XML hater. For "fun" (what there is of it in this industry anyway!) I often have the "XML is a binary format, no it isn't, yes it is" argument with those who spout one of the advantages being you can edit in Notepad, and therefore it's great.

I reckon a large percentage of developers don't realise XML is *very* case sensitive (therefore binary) until they've wasted a good couple of days tracking down a bug.

It's a symptom of these bigger and bigger libraries (e.g. .NET) that mask all the underlying functionality these days. Newly trained guys just don't have a clue what's going on underneath. No names, but one of the guys where I work is desperate to get .NET 2.0 - no, make that .NET 3.0 - and SharePoint and BizTalk and XML is great and AJAX and God know what else... and yet couldn't point at the Least Significant Bit given a large pointy stick and a big clue.

Maybe I'm just getting old, but things sure ain't what they used to be 'round here. No, sir.

Edited by Spyke on Tuesday 24th October 23:19

TheExcession

Original Poster:

11,669 posts

280 months

Wednesday 25th October 2006
quotequote all
Top replies lads, it's good to know that I'm not alone in my 'old ways' of thinking.

As people say, I'm encountering more and more of it, I think one of problems is that people just assume it's the best thing to use, and sure it is ok for describing heirarchies, and as has been mentioned people just use it without really thinking about what they are doing, or without the experience to understand the ramifications of the structure and the way it is used.

To me it smacks of the code that I see coming out of India, where the rule of the day seems to be why do something in 10 lines of code when you can do it worse with 30...



m12_nathan

5,138 posts

289 months

Wednesday 25th October 2006
quotequote all
victormeldrew said:
I've never been a great fan of relational databases (and I've used them since before Oracle was a glint in Rdb/VMS's eye!); XML is great for me because it is very similar to the multivalue databases I know and love - variable length, tag delimited, hierarchical data. Perfick!

Don said:
Its a sodding hierarchical data structure - and I thought we'd got rid of those years ago when we got ourselves relational databases...
You thought wrong Don!

Edited by victormeldrew on Tuesday 24th October 23:39


You can represent relational data in XML too though.

dern

14,055 posts

309 months

Wednesday 25th October 2006
quotequote all
I'm always suspicious of someone who says they don't like something like xml. Chances are that if you're in that position then it's being used in the wrong context and it's that issue you need to be looking at. It's a very powerful format with many plus sides but it isn't always appropriate. Given the number of tools available that either convert an xml document into either a hierarchical structure or exhibit sax parser like behaviour by firing events on certain objects it's difficult to see that even if you have to use it because of some constraint that you can't write code using one or other approach to ensure that you get your data in the correct order at the correct time. If you still can't then someone has chosen the wrong technology and you should address that rather than blame the problem on a file format.

Regards,

Mark

GnuBee

1,339 posts

245 months

Wednesday 25th October 2006
quotequote all
Fraid I'm with dern on this one. XML, .NET, ADO etc etc are just tools in the box - you select the most appropriate tool to do the job with.

I do agree with the point (Spyke) regarding the fact that the majority of new programmers do not seem to understand their dependencies. There appears to be a general lack of awareness of how things are working underneath the niceties of the average .NET namespace for example.

The real question has to be; are these tools actually facilitating better systems, more productivity and easier support or not?



dern

14,055 posts

309 months

Wednesday 25th October 2006
quotequote all
GnuBee said:
The real question has to be; are these tools actually facilitating better systems, more productivity and easier support or not?
If you've chosen the right tool and it does what it says it does then yes. If something seems difficult or inapporiate you need to go back to the team and discuss why it's been chosen and the chances are either you've misunderstood some aspect of the problem or the wrong tool has been chosen and resolve the issue.

JonRB

80,121 posts

302 months

Wednesday 25th October 2006
quotequote all
The knub of the original post is that you have a system that can only accept serial data and you're moaning that you can't cope with non-serial / random access / hierarchical data like XML and that it's XML's fault somehow. If someone was throwing a binary format at you, would you moan that it was crap too?

The simple fact is that your system's architecture can't cope with XML as XML makes no guarantees of the order of the nodes in a hierarchy. Your system needs ordered, well-defined data, and XML is not that.

I don't see what the problem is here.

Edited by JonRB on Wednesday 25th October 11:37

PetrolTed

34,468 posts

333 months

Wednesday 25th October 2006
quotequote all
I was a late convert to XML. I think it's wonderful now. Really, really useful.

TheExcession

Original Poster:

11,669 posts

280 months

Wednesday 25th October 2006
quotequote all
GnuBee said:
Fraid I'm with dern on this one. XML, .NET, ADO etc etc are just tools in the box - you select the most appropriate tool to do the job with.

Indeed but I'm stuck with around 70,000 lines of legacy code that neither the customer or I can afford to port upto the latest standard.

I'd love to to import this whole lot into .NET (J# for example), but unfortunately every time I've tried this the import Wizard seems unable to convert the GUI Form definitions properly which means I lose the Form Editing facillity in .NET.

Bummer, I have about 100 hundred different forms in the project, I just haven't got time to sort through them all and recode them in the .NET IDE.

Sounds like a job for a YTS? Do they still do that?

TheExcession

Original Poster:

11,669 posts

280 months

Wednesday 25th October 2006
quotequote all
JonRB said:
I don't see what the problem is here.

I wanted to moan about something that's all...




still f**king hate xml though.....

TheExcession

Original Poster:

11,669 posts

280 months

Wednesday 25th October 2006
quotequote all
JonRB said:
If someone was throwing a binary format at you, would you moan that it was crap too?

Maybe maybe not, impossible to say.

But my line of work is generally in 3G and satellite protocols, it's a situation where you can calculate the cost of every single binary bit that goes over the air.

Consequently these protocols are increbibly tight and information is carefully thought out and packed into the least amount of space possible. You know exactly when and where you are going to get a piece of information.

It breaks my heart sometimes to see the amount of work that goes into designing these systems only to look at the data they are then used to carry - bloated, ugly, and often ill thought out.

There's no need for XML in its current form apart from to satisfy the fact the people 'like' to be able to read it in Notepad and think this is a bonus.

In terms of storing data on a disk then yes I can see how it might have some advantages, but as a communication mechanism between two computers, especially over a limited resource medium it's plain terrible.

I just hate it, I hate the way it is being used and I hate the fact it's touted as the best thing since sliced bread. It flies in the face of everything I have ever looked at and thought, that is a way cool solution to a problem. It's just ugly, wasteful of resources and incredibly long winded.

All in my humble opinion.