No One Needs Abstractions Until They Do

| No Comments

If you read blogs.perl.org you've probably seen a debate over whether some of the libraries often lumped into "Modern Perl" are necessary.

You may also have read Perrin Harkins's Fond Farewell to CGI.pm, which does an admirable job of sending off that venerable piece of code many of us remember far too well. Back in the olden days, a lot of us spent a lot of time converting a lot of standalone CGI Perl programs to use CGI.pm instead of a hand-rolled parser copied from too many places on the Internet that didn't have a clue about security or performance or correctness. If we were lucky, those scripts were Perl 4 and used something called cgi-lib.pl, which at least made an attempt to be useful in multiple places.

The CPAN was a revelation. It was an oasis. It was, all of a sudden, the solution to problems we didn't know we had.

I find no small irony in a few posts asking whether there's any reason to use Moose or Mouse or Moo when you can write your own object accessors by hand (I wrote my own templating system by hand too. No more.) juxtaposed with a farewell to the library that convinced me that the CPAN was here to stay.

Sure, I wrote a handful of very small programs that didn't use CGI.pm or anything like that because they didn't even need that much. (I wrote my own web server in the late '90s, because it seemed interesting.) Yet every time one of those programs grew a little bit larger, a little bit more of what CGI.pm provided became more useful. Cookies? Handled. Persistent form values? Handled. (Oh, what a glorious thing that was!) A new RFC I didn't know existed (if I even knew at all what an RFC was)? Supported!

I kinda feel the same way about some of the pieces of what I call Modern Perl.

For example, I know I could build something like XML::Rabbit on my own, if I had to. I could also parse XML by hand, or with a regex tokenizer, or with XML DOM methods.

I don't have to.

I know Robin could have written XML::Rabbit without Moose. Sure, its interface would be a lot clunkier. It would have taken him a lot longer. It might not even exist without Moose.

Thankfully, the Perl world has Moose and things like XML::Rabbit built on top of Moose because Moose exists and is stable and is usable and gets used.

Again, there are people parsing XML out there the Perl 4 way, and if they're getting their jobs done, then thumbs up for pragmatism. If all you need from one document is just a tiny little piece of information, by all means use the simplest thing that could possibly work, for whatever definition of "work" makes sense in your context.

Yet when I look at the code I wrote back in 1998 and compare it to the code I wrote in 2008 or just today, I see how much more I can do (okay, a decade and a half of experience helps a little) with less, because the language and tools and libraries have improved that much. By all means, mist up when you think about CGI.pm, but to claim that everything since then is unnecessary bloatware that doesn't do anything you couldn't do by hand?

Sure, maybe you could do everything by hand. If that's your idea of fun, more power to you. If that makes the most sense for your business rules, good for you for being pragmatic and letting something other than shiny programmer magpie syndrome inform your decisions. Yet you'll not often catch me shunning improvements to productivity and capability. I'm too lazy not to work hard to keep up with new ideas, because some of them (Moose, testing, higher-order programming, Unicode, Perl itself) change the game so much they define the game.

You can't afford modern Perl in your environment? That's fine. That's the case for many uses. I can't afford not to have modern Perl in mine.

Leave a comment

Modern Perl: The Book

cover image for Modern Perl: the book

The best Perl Programmers read Modern Perl: The Book.

affiliated with ModernPerl.net

Categories

Pages

About this Entry

This page contains a single entry by chromatic published on June 24, 2013 6:34 PM.

Why dots.pm Was Not My Favorite Feature was the previous entry in this blog.

Use Test::Most for Quick Debugging is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.


Sponsored by Blender Recipe Reviews and the Trendshare how to invest guide

Powered by the Perl programming language

what is programming?