Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Knowing and understanding the efficiency of basic language constructs is part of mastering a programming language.
This. The "methodology" of writing whatever arbitrarily-inefficient code you first think of that produces the desired output, then doing a bunch of profiling followed by tweaking and/or extensive rewrites, is a blight. If you write something both readable and reasonably efficient in the first place, there's a good chance you won't have to mess with it later. Having a clue about hardware and data structures really pays.

This, by the way, is why I've always been annoyed by the "ArrayList" in Java (don't get me started on the "HashArrayListWhatever" used in Lua): depending on your expected access patterns, you'll want either an array or a list. In some cases, you'll want something fancier or more specialized. Arrays give you fast random access and slower insertions; doubly-linked lists give you fast insertion and slower random access; singly-linked lists give you fast insertion at one end with minimal space overhead; balanced trees scale well for most operations, but have a significant constant penalty. If you start out with the right data structure, you may not have to bother with laborious profile-guided optimization.


In reply to Re^2: The Rules of Optimization Club by educated_foo
in thread The Rules of Optimization Club by petdance

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 taking refuge in the Monastery: (4)
As of 2024-04-19 02:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found