[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: parsing markup with Perl

  • From: Michael Sokolov <msokolov@safaribooksonline.com>
  • To: Arjun Ray <arjun.ray@verizon.net>, "xml-dev@l..." <xml-dev@l...>
  • Date: Sun, 09 Feb 2014 07:54:24 -0500

Re:  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]


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.