quasi random (kaolinfire) wrote,
quasi random
kaolinfire

a new appreciation for perl

For a long time I tried to understand what people saw in perl. I knew the language well enough to know that it was a sloppy mishmash; yet people I considered intelligent used it and liked it -- many great people swear by it, and not just to hack shit together.

I was confused. I dabbled in perl; I did one reasonably large project in it (with a lovely little memory leak that popped up a couple months into the live site... did you know you could have memory leaks with perl? it was due to some "nifty" shared memory stuff I was doing to handle sessions; perl lets you do all sorts of hackish stuff and doesn't raise a whimper).

c, which I love, lets you have all sorts of memory leaks if you're not careful... but the mood is different. with c you must be careful. it is a fine crystalline machine with delicate tolerances that can move with great speed and precision when set right.

But perl was icky. It just wasn't right. I stuck with "real" programming, or did bash scripting when I wanted to hack something out that could be done easily as such.

That was how it was for me, for a few years.

An epiphany hit me. perl really is a robust and elegant language. What I was missing was the fact that I didn't know it well enough. I was mangling it. I could make things that worked, but that wasn't the point. I used perl carelessly and didn't see that that was exactly what I hated.

My longstanding appreciation of English (the only analog language I know), is much the same. But I know its little tricks. I know how to use it properly, and with that comes the knowledge of what rules to break when, how to have a certain style within and around the rules of communication. It really bothers me to see someone (a "native" speaker) mangling the language when they don't even understand how they're mangling it. That's what I was doing with perl.

I recently did two small perl scripts; they were hacks in that their existence shouldn't have been necessary. One was a control script tossed into the crontab because certain things on the system were going awry. It would check top to see if any processes of a certain type had gone rogue, and if so would clear them and allow that section of the system to restart. And as perl, it was a very clean script. I suppose I could have used sed or awk, but perl was more intuitive. Elegant.

The other script was due to a filesystem overflow. Errors were logged in such a way that much of the lost data was actually just misplaced, in the wrong format. So a script was quickly made to turn the appropriate parts of the error log into SQL INSERT statements, and the problem was resolved. Quickly, cleanly, with perl.

Of course, those were very small things. I'm not saying perl is only elegant when small. I've done a (tiny) amount of hacking on vicq, for instance, a lovely commandline icq clone written in perl, and I can see the elegance in that as well. I understand, if I don't quite grok that understanding yet. Mind you, I'm going to stick to my strongly typed languages for most things. But I finally have an appreciation for perl, and I'm so glad for that.
Subscribe

  • A year of poetry and fiction....

    It doesn't feel like much (I haven't been writing, mostly), and I've not been submitting like I need to, but somehow I managed to succeed…

  • GUD Issue 5--is ALIVE! :D

    What's not to love??? Issue 5 ... WRAPS A SCIENTIFIC CORE WITH OUR MOST ECLECTIC SELECTION TO DATE—including two "mini graphic novels", and a…

  • Preditors + Editors Readers' Poll

    Probably 9/10 of you have already either put your votes in or decided you're not interested, but this is my last-minute plea for the other two of…

  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 7 comments