XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] parsing markup with Perl

On 2/8/14 4:08 PM, Arjun Ray wrote:
But why blame Perl, other than it's the language eveyone loves to
hate?  (Actually, I thought that would be C++.)


I think it's because regexes (*real* perl regexes, not the pale imitations purists refer to as "regular expressions") are so easy to use, convenient, and powerful in Perl, unlike other languages (cough, Java I'm looking at you). Python has them too (and Javascript - I guess we have to include that now), but re's in these are not first-class language constructs the way they are in Perl. Perl practically cries out to the programmer "use regexes! I will give you magically-scoped variables with all your capture groups. I will drive your iteration using /g. Your program will be super compact! No more RSI!" Who cares if your code is unreadable and undebuggable. If you're sane, you'll use Perl primarily for one-time text-processing tasks.

I will confess to having built a complex account/subscription management system including a web application in 1999 that is still in operation today in Perl, that uses regexes to parse its templates, which are in a homegrown subset of XML not too far from MicroXML that I stumbled into using because I didn't bother to learn what XML syntax really required to be parsed. I would never do this today, but the fact is the system actually works fine. Several other people have had to learn it and perform major updates, and this seems to go fairly smoothly. The pseudo-XML templates in particular and their parser (HTML::Macro) have never caused any trouble in the least. They are not used for interchange with other systems, so standards are not really particularly relevant, and besides they include potentially ill-formed HTML, unescaped, something I never could have achieved with a *real* XML parser. We fix them when we find them, but in the meantime, no real harm is done. So I think there are places for parsing markup with (perl) regexes.

I do agree that Perl lends itself to confusing coding idioms, but at least it doesn't have inheritance (not really). Java programmers I have worked with seem to have become so deliriously enamored of formal conventions ("patterns," they call them), that they tend to ignore the actual problem at hand. "Ah wait!" they say, "here is an opportunity to decorate the interface with a delegation facade!" Every language has its pitfalls. C++, yes, very scary traps, but in the end I find that bad taste knows no linguistic bounds. Bad programmers will be bad.

-Mike


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS