Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Comment on

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

There are good and bad abstractions. Speaking purely in terms of computational efficiency, a good abstraction gives an optimizer more information about what you're trying to do. Optimization is basically about reconginzing that there are multiple ways of compling a given bit of code, and the Programmer shouldn't have to worry about what the best way is.

Speaking in terms of programmer efficiency, a good abstraction will allow the most work done with the least amount of code. A good language will aim for the easiest way to program something to also be the most computationally efficient. For instance, a Perl programmer who has a large ammount of data indexed by a string will often automatically reach for a hash. Which is great, because a hash is likely the most computationally efficient way, too.

Now, Class::DBI gets tripped up because it can't get enough information to create the SQL. Consider this Law-of-Demeter-breaking snippet for getting through a few joined tables:

my $table3 = $table1->table2->table3;

If we were writing raw SQL, we could get this in a single SQL statement with a three-table join (which is hairy, but possible). But because Class::DBI has to fetch each table individually, a lot more SQL would be needed (I'd have to dig through the source to know just how much, but it's definately more than a hand-optimized version).

So this is a case where the abstraction makes it easy on the programmer, but hard on the computer. Maybe that's OK, and maybe it isn't. It all depends.

"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.


In reply to Re^3: Appropriate amount of abstraction by hardburn
in thread Appropriate amount of abstraction by gunzip

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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 drinking their drinks and smoking their pipes about the Monastery: (5)
    As of 2014-12-27 05:35 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (176 votes), past polls