perlmeditation
FoxtrotUniform
<p>It just occurred to me that what I like most about Perl
is the number of compact features and idioms that it makes
available.</p>
<p>What originally got me hooked on Perl was its regular
expressions: sure, they looked hairy to a beginner, and
the more I find out about them, the hairier they look, but
they're an excellent compact way of matching patterns, or
pulling information out of a formatted string. What once
took me 150 lines of (albiet non-optimal) C can now be done
with 50 characters. Wow!</p>
<p>The next idiom to hit me like that was <tt>map</tt> and
friends (<tt>join</tt>, <tt>grep</tt>, <tt>split</tt>, and
so on). List operations that I'd originally spent dozens
of lines on can now be done with just one or two. And
don't get me started on the Schwartzian Transform.... Wow
again!</p>
<p>Now I look at Perl 6, especially Apocalypse 3, and
especially its hyper operators, and my hands start to
twitch, and my eyes glaze a bit. And I write some Prolog,
and I look at the binding operator, and the backtracking,
and the other features that might make imperative Perl
practical and worthwhile, and it looks even better.</p>
<p>This gives the impression that I really like compact,
even golf-ish, constructs. I do, but that's not the point.
I like being able to express myself tersely and easily,
with a high ratio of semantics to syntax. (Writing
featureful, functional code that makes other programmers
grimace at its density is also kind of fun, of course.)</p>
<ul><b>Update:</b> I should note that I <i>don't</i>
(deliberately) write obscure production code. I'm well
aware of my own limitations regarding understanding my own
code three months (or days...) later, and I'm blessed with
a few co-workers who are willing to comprehensively review
my code. Those two things combine to keep my code from
getting out of hand.</ul>
<p>I'm sure that I've missed something: some other idiom
that collapses many operations into something terse,
compact, and expressive. That's one reason why I'm writing
this meditation: to find out what I've missed. Another
reason is to get a discussion going on compactness in Perl
(and programming languages in general): do the benefits to
an experienced programmer outweigh the hairiness involved?
Thoughts?</p>
<tt>-- <br>
:wq</tt>