tyggerjai: (Default)
[personal profile] tyggerjai
This post is brought to you by recent excursions in The Lacuna Expanse. You can probably skip this post and go straight there, unless you're a perl weenie. If you *are* a perl weenie, you may enjoy TLE. Not only is their API published and well documented, they encourage scripting and bot writing. You could, legitimately, write a bot to run your entire empire, and never log in again, and they'd be cool with that.


Anyway.
I have never been a fan of perl's map function.

There. I've said it. It confuses me, and makes me feel stupid. Partly, of course, this is self-fulfilling - I don't like it, so I don't use it, so I don't understand it when I see it, so I fear it, so I don't like it ....

Working in Lisp a bit recently has, oddly, increased both my understanding *and* my dislike. So I'd like to be educated.

Dear perl hackers. Does map give me *anything* other than syntactic sugar, or perhaps the opposite?

Part of this stems from recently getting up to speed with Python, which has Only One Way To Do It, which means, when you see It, you know exactly what It Is Doing. I've been reading a lot of other people's perl lately, some of it quite old and crufty, and I'm struck by the tendency of perl hackers to be clever. And that's nice, and all, but sometimes it's not. And oh, I know, the community is diverse and all, but it does my head in to go to "help" communities that emphasise clear and readable code, and then say "And you know that annoying 4 line foreach loop? You can replace it with a single line of incomprehensible punctuation using map, in case carriage return is expensive on your machine!".

Which said, I may be missing something. Should I be using map, and if so, why? What does it give me other than shorter code? Do you find it just as easy to parse as a nice foreach loop, or can you do things with it that you just couldn't do with foreach?

On a related note, I think this has something to do with my innate distrust of "$_". I know, I know, "$_" is a defining characteristic of the language, but still. It's *clever*, and I don't always like clever. So map not only generally has $_ scattered throughout, but by definition, when reading it, you get to $_ before you have *any* idea what actual set the map is working on.

This, I suppose, is why I no longer code for a living, but I wonder how much of it really does just have to do with perl.


Profile

tyggerjai

Прекрасное Далеко

Слышу голос из Прекрасного Далека
Он зовет меня в прекрасные края
Слышу голос голос спрашивает строго
А сегодня что для завтра сделал я

Expand Cut Tags

No cut tags