After my years of hacking Perl, and trying to learn and compare it's speed to C and C++, this is what I have concluded.

1. The "script compilation phase" of running a Perl script is NOT the cause of it's slowness, compared to C. What makes Perl run a bit slower than C, is that Perl stores all variables in structures, which hold the variable, along with it's attributes, like type of variable, number of references, etc. This slows Perl down, when running long computation intensive scripts. However, this very same thing also makes Perl easier write and use. Try doing some simple tasks in C or C++, and you end up spending half your programming time trying to figure out "casts" and tracking what form digital data is currently in. It is why so many C, C++ programmers switch to using Perl, (or other scripted language). There is also the "buffer overflow" problem, which plagues C, which is just a "distant memory" for Perl programmers.

2. If you need more speed, it is far more economical just to buy a faster motherboard and harddrive. A Perl script running on a 2 Ghz machine with SCSI harddrives, will generally outperform a C program running on a 500 Mhz machine with IDE drives. So you can upgrade hardware for $300, instead of paying a C programmer $500 a week to boost your performance by 500 milliseconds per run.

Of course there is always the place for C, in the underlying libraries, etc., but in general, Perl performance is very fast just the way it is, (assuming you write scripts correctly). :-)


I'm not really a human, but I play one on earth. flash japh

In reply to Re: High Performance Perl by zentara
in thread High Performance Perl by willyyam

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.