Ruby + XML = Suck.
I’ve been wanting to learn ruby for a while now, and I finally had a project at work that seemed like it would be great to learn the basics on. I could have coded and debugged it in Perl in a couple of hours, but it was the last step in a larger project and I had the week to work on it.
Pulled out the fresh Programming Ruby book (Which, btw, I would not recommend) that the library had purchased. Read over some of the example programs to get a feel for the syntax and went to town. 15 minutes later I had a scrip that read in the XML data (a 17mb file, with ~3500 items), spit out some results.
Things that i noticed right away:
-
ReXML, the default XML parser for RUBY is horribly slow. By ‘horribly slow’ I mean, you may as well go get lunch while its reading in your data. In Perl that same file loads in less than 1 minute using XML::Simple. In Ruby using ReXML, 8 to 10 minutes depending on machine load. Then, you have to go through the data which involved a couple calls to the ReXML library. Another 8 to 10 minutes.
-
ReXML expects all XML transformations to come from XSLT. This is all well and good, i guess. But what happens if you don’t want to, or can’t, use XSL? The DTD for this particular spec does not allow for a style sheet. In fact, if you assign one in the XML the program that reads in the XML file will fail because it does not expect it … so XSL isn’t an option for me.
What do you do if you need to do something as simple as sorting the XML data? Throw it into a Ruby Hash, then sort it.
Ugh.
I plan on using Ruby a bit more, with the exception of XML it seems pretty nice. But if you have any XML projects, you might be better off programming it in BrainFuck than ruby. It would be faster.
RSS Feed