Rather frequently I seem to hear Perl people bashing XML, and almost always for the wrong reasons. I'm not interested in outrageous advocacy, there's no point in converting people to something if what they already have is good enough :)
I'd just like to know people's reasons for not liking XML, so that perhaps a little debunking could take place. Most of the stuff I hear talk about the complexity of specs that I've never needed getting in the way, and various other such mythological monsters.
I'm not insane, I don't like verbosity, heaviness, complexity, and other such things. I use XML because it's the closest thing I've found to a Unix pipe that could carry consistently structured information. So somehow there are two perceptions hanging around, and I'd like to find out why ?
I'm also hoping it's not because of the "everybody else is doing it so Perlians get to do it some other way" approach to things which some people tend to have when they think that building a bigger wall around themselves creates a tighter community.
First, there are a few "leading minds" in the Perl community that are quite vocal in their strong dislike of XML for it's verbosity. Similarly, there are some "leading minds" in XML that are quite vocal in their strong dislike of Perl for it's syntax.
(This doesn't explain why there are those "leading minds" in both Perl and XML that like two tastes that taste great together.
The second important reason was best articulated by Gnat "I'm no huge friend of XML" Torkington at YAPC 19100: Perhaps XML isn't well suited for Perl's areas of strength -- system administration and duct tape. That's actually a corrolary of one of his axioms about Perl: Perl is used the way real people solve real world problems; if Perl isn't heavily OO, it doesn't necessarily mean that Perl is behind the times, but it might indicate that OO isn't the savior of the world it's proponents say it is.
So, gnat's point isn't that XML sucks, but rather that XML doesn't solve as many unsolved problems it claims to -- it simply solves them again differently.
You can also take this as an indication that Perl isn't heavily used in the domain of application building, where XML is significantly more useful; that would explain the rabid update of XML with Java and Python, compared to the lukewarm uptake of XML with Scheme and Smalltalk...
Re:Perl vs. XML
darobin on 2001-12-13T18:55:54
Yes, I can see your "leading minds" argument, but on the other hand if the idea is to get one's job done, then listening to the tools and exploring their potential power is probably a better option than listening to other people, even those that are right (ie your third category
;-) When it comes to Perl's strengths, I beg to differ. For one, Perl has long become good at much more than sysadmin tasks. I think that those hardly represent 2% of what I do with Perl. More importantly however, it is a great glue language. And that is precisely one area where it plays well with XML: XML is a glue grammar. Yeah, people tend to prefer words like interoperability, but at the end of the day, XML just happens to be great glue.
When you mix Perl's program glue with XML's syntax glue, you get something tremendously powerful. We all know the glueing powers of the former, some seem to ignore those of the latter. You never need to write a new parser, they all read it the same way. Better than that, using SAX you never need to care which parser you use as you get a common interface. Better still, if you have a parser that parses non-XML formats, a SAX interface to it will make it look like XML, thus enabling your existing XML apps to use it directly. Further again, using namespaces means that you can take small, task specific vocabularies and bundle them together into a single document, each of them being used for the simple purposed they were designed to serve (and then again, tools made to process just one of those small vocabularies will work on the whole document, and can be combined in a pipe to make sense of the entire doc). That's only the start, there's much more in there.
Perl and XML is a match glued in heaven.
Moving ahead in your argumentation, XML is also "used the way real people solve real world problems". It's not something made for pure academics, or for PHBs. I know a lot of people out there are trying to make others think it's really complex and needs their products to be used. That's just marketing propaganda. Throw away all those schema languages and you can have the ultimate immediate problem solver: a quick-and-dirty vocabulary, for which you already have parsers and tons of tools. As with Perl, XML can be used for tiny menial one-shot tasks, as well as for very elaborate and well-constructed ones. The rules for Well-Formed XML are dead simple. It is not by mere chance that the XML design docs mention the DPH (Desperate Perl Hacker) as one of the most important use cases.
This has been hi-jacked by ComplexityHeads from JavaLand. But in essence, XML was made for us Perlians. That essence is still there, waiting to be used by those that it was intended at.
You also mention OO. Perl is not heavily OO, and -- surprise ! -- neither is XML. The problem here is that data typing and OO typing have impendance mismatches (anyone that has tried to do RDBMS-OO mappings knows that). Trying too hard to retrofit data typing into OO typing is probably one of the leading causes for XML Schema to be that awful beast it is. Thankfully, you don't have to use XML Schema. I use XML all day and I've never needed it. DOM is another case of OO mismatch. It managed to stay useful by addressing only a very low level view of XML, and thus having very little typing of its own. Again, if you don't do low-level XML programming you will probably scarcely need the DOM. I do low-level XML stuff, so I use it here and there, but overall it's avoidable.
On the other hand, Perl's flexible approach to typing makes it excellent at dealing with XML.
As for solving unsolved problems, well... what does ? Perl doesn't solve unsolved problems either. It, too, just solves them differently. Differently is the operative word here. Differently means it has a chance of doing it better. I think XML, like Perl, scores well in that regard.
Finally, XML isn't good just for app building. It's good whenever you need a simple, reusable, data format that has an open door for extensibility and many other nifty things _when_you_need_them_.
Wow, that was a long one. I hope I don't get more than a comment a day on that one
;-) Re:Perl vs. XML
ziggy on 2001-12-13T19:38:51
Whoa, this is a huge one.:-) When it comes to Perl's strengths, I beg to differ.
I think I hit the send button too soon. Usually when I enter into this discussion (it's not the first time), I describe sysadmining and duct tape as Perl's historical areas of strength. That adjective is quite important.
:-) By no means should that be taken to imply that Perl is a poor language for application programming. I certainly agree with your POV about XML being great glue, and Perl and XML being made for each other. Larry has made it known that he wants Perl to embrace XML, regardless of what well-intentioned curmudgeons in the Perl community say about it.
We all know the glueing powers of the former, some seem to ignore those of the latter. You never need to write a new parser, they all read it the same way.
This is actually another issue with Perl - because of excellent regex integration Perl programmers have tended (note past tense here) to roll together a couple of regexes instead of writing a parser. Sure, writing a parser is hard work, but the typical Perl programmer doesn't do it all that often. This is actually one of the good things about Perl, and the interaction here is quite unexpected.
Anyway, you don't need to convince me. I'm a huge fan of Perl and XML together. It's just that a lot of time has been spent over the last 4 years trying to figure out why the uptake of XML by Perlfolk isn't as quick as has been by Javafolk. These are some of the reasons which I think help explain the differences, not justify them.
Next time we're at a conference together, I think I owe you a beer.
:-) Re:Perl vs. XML
darobin on 2001-12-13T20:55:30
Yes, the fact that it's so easy to write a "semi-parser" parser in Perl certainly doesn't help make XML as popular as it could be, especially for the quick and dirty stuff. Good point there. However, I'd like to say "Why even write a small and easy parser when you could avoid writing one altogether ?"
;-) I wasn't trying to convince you
:-) I know you're not on the anti-XML side. I just felt that I had a few arguments to underline in reply to what you said, and, err, maybe I went a touch overboard in length. I was also aiming at making those reasons unusable as justifications for those that would use them there. I'd be delighted to swap a few beer rounds at the next conference where we meet
:-) I guess that would be TPC for me.