Let me say first that I find this kind of discussion of internals and performance impact interesting. A character class with one item is not the same as a literal one item. Fascinating!

That said, I find this kind of statement irritating:

Don't apply "Best Practices" without fully understanding the underlying mechanisms.

The "underlying mechanisms" go pretty deep. You seem to be making reference to the implementation of Perl, in C, but there are mechanisms underlying that too. Should one also understand the underlying mechanisms of the C compiler? There's the OS. There's the hardware. There's physical science that explains how the hardware works.

These are all underlying mechanisms. There are performance differences in simple arithmetic from architecture to architecture. There are differences from version to version of the compiler. I don't think that it's worth my time to study all these things to figure out the very best way to implement something. I don't feel obligated to plumb the depths of computing to justify my decision to use one practice or another.

What I think is important is readability and maintainability (after, of course, functionality). The best way to write code is the way that makes it easiest for the programmer and the programmers who come after. At some point, performance becomes a functionality issue. At that point, it's time to do some profiling and optimize where it counts. Before that point, time spent optimizing is time wasted.

Part of the point of best practices is precisely so that one does not have to learn every detail of what underlies the advice given. Call me selfish and lazy if you like, but I want the benefit of others' experiences without paying the price of those experiences myself. I admit those experiences have value that I might perhaps miss sometimes, but they also have a cost in time and energy. Here again, I don't feel obligated to go exploring a place if someone has already made me a map.


In reply to Re: The cost of unchecked best practices by kyle
in thread The cost of unchecked best practices by moritz

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.