The usual wisdom is -- if you want to do something fast, write it in C. Hence the plethora of XS modules, and the usual annotation: "The heart of blah blah is written in C for decent speed."

Of course, Perl itself is written in C, so I ask this -- other than the benefits that an interpreted language brings -- rapid prototyping and development -- once I have got my script working, why is it that I can't compile it and get the same level of speed that a native C program would get? Is there a technical reason, a philosophical reason, or is it because doing so would break a law of physics? And, no, running perl scripts inside mod_perl is not a solution here. I am wondering why is it that I can't compile perl scripts to honest-to-goodness-bare-metal-programs-such-as-those-coming-out-of-the-other-end-of-gcc? Wouldn't that be the best of both worlds? I would be able to program faster in Perl and be able to write faster programs in Perl.

Bonus question -- I often read arguments for and against strict typing vs. no typing as in Perl. Other than possibly catching errors and thereby making for more robust programs, strict typing doesn't by itself contribute to any speed gains, does it? It seems like just an excuse for macho programmers to snigger at sissy programmers such as me?

--

when small people start casting long shadows, it is time to go to bed

In reply to 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.