Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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

    Update: I should note that I don't (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.

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-29 10:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found