It just occurred to me that what I like most about Perl is the number of compact features and idioms that it makes available.

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!

The next idiom to hit me like that was map and friends (join, grep, split, 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!

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.

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.)

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?

--
:wq

In reply to Compactness by FoxtrotUniform

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.