The issue of "best" is very deceptive. Best how? I've said this in a number of nodes, but I'm going to say it here all laid out.

The best language when it comes to CPU and RAM usage is machine language. You cannot do better than machine language. At all. No way. The best compiler will only match the machine language implementation, and usually not even come close.

However, development time in machine language is extremely slow. Like, slower than that. And, maintenance is even harder. This is why we use higher-generation languages.

Now, every 3+G language has tradeoffs. Each language's syntax lends itself to certain applications. FORTRAN is excellent for engineering/math. COBOL is excellent for business apps. Haskell for functional, etc. In addition, different compilers do different things well. You can compile the same C program with two compilers and one will have better RAM, but worse CPU. The other will be reversed.

Perl, that 4G language we all know and love, has been optimized for development time. Now, what does that mean?

It means that no matter how I think about it, I can get a functional program that does what I want it to do in a reasonable amount of time.

It means that I can write one-offs quickly and efficiently and "Get The Job Done". (GeJDo? Maybe GAJD for Get A Job Done? I dunno.) Remember that human time is the most expensive part of a development effort.

Does this mean that Perl cannot do all the things other languages do? Yes, it can ... and "Well Enough". Perl is, as we all know, a RAM hog. It can also be a CPU hog. This is part of the tradeoff for having lightning-fast development time.

Now, what does this all mean?

It means that "Good Enough" should be your mantra. You can always optimize. You can always rewrite your thing in machine code, if you really wanted to. However, you have to determine when the gains made in runtime performance are not worth the value of the (re)development time needed to achieve those gains. At that point, you have hit diminishing returns, and should probably stop.

If your program works, it doesn't matter if the template is perfect or if your for-loops are optimized or whatever. Are you going to reuse the template? If not, then leave it alone. If you are and the rewrite would help you when you use it again, then go ahead and rewrite it. Otherwise, leave it alone.

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.


In reply to "Get the Job Done" (GeJDo) by dragonchild
in thread Too Many Ways To Do It by George_Sherston

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.