why is it that I can't compile it and get the same level of speed that a native C program would get?
Because compiling still doesn't give you the speed C gives. Take for instance strings. In C, strings are just pointers to arrays with numbers. You cannot, in a single operation, add to a string. And it's even a lot harder to have all other references to such a string see the change.

In Perl, this is a lot easier. I can easily add to a string. If there's a reference to the string I'm modifying, the reference will see the change. All this makes that Perl is a lot slower than C - it's all the goodies that Perl gives to the programmer that makes it slower, that has a much bigger impact that the difference between compiled and not-compiled.

If you need speed, by all means, use C. If you are willing to sacrifice speed for programmer niceties, you have the option to use Perl.


In reply to Re: compiling perl scripts aka why is perl not as fast as C by JavaFan
in thread compiling perl scripts aka why is perl not as fast as C by punkish

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.