Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Don't mind me, just a caffeinated ramble.

I think there's simple, there's efficient and there's idiomatic. Simple code is readable by nearly anyone with a general grasp on programming. Efficient does the task with the most efficient use of whatever resources are important to that task. Idiomatic code takes advantage of language features to clearly express an idea more succinctly. Idiomatic code is probably less readable to an unexperienced Perl dev, but perhaps more readable for the enlightened. Because performance is rarely an issue for the code I write, I usually shoot for simple and/or idiomatic and shuffle the code that must be unclear for the sake of efficiency into the dark corner of some library.

My guideline is that clever code is none of the above. Okay, really good clever code may be efficient, but it usually isn't. Most of the clever code I've come across is little more than exploring language features. "Did you know you can do X in Perl?" That's great at home, but I restrict my production code to the idioms I'm most familiar with. Yes, my old production code was simplistic to the point of irritation. Yes, some of my new production code would make a Perl novice twitch while still having simplistic spots that might irritate a guru. But I'm fairly confident that today I could go back and fix a bug in any of my production code. The coders who produced that "clever" code I hate probably couldn't. They've moved on to other features or other languages and probably couldn't even remember why that class needed operator overloading which was so sensitive to calling context or why they had to write the half the logic in an evaluated regular expression.

There's nothing wrong with being clever. It's fun and you learn from it. But I think we use "clever" as a pejorative when it looks like the original dev was just going "look what I can do!"


In reply to Re^4: "Cleverness" from HOP by webfiend
in thread "Cleverness" from HOP by Wiggins

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, 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, 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.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (4)
    As of 2020-07-07 09:44 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?