One thing to consider when evaluating "why" Perl is (generally) slower than a compiled language, like C, is that tokenization and parsing happens once for compiled programs, but every time you run a Perl script.

As for speed in general, I imagine it depends on what you do with the language. My only data point is on some fairly brute-force statistics (regression analysis): I ran pretty much the same program in C and in Perl, and the C program ran about 200 times faster. I suspect that Perl is much closer to C in areas like string manipulation, where Perl has very heavily optimized (C) primitives. Keep in mind that, since Perl is implemented in C, optimizations being equal C will always be (even just a little bit) faster than Perl, since Perl scripts will be running code written in C, plus the tokenizer and parser.

Language speed depends heavily on how good an optimizer the compiler or interpreter has, and how well it can take advantage of the hardware. That said, program speed is often dependent on the algorithms you use, not the language; if speed is important to you, choose a language that makes writing quick algorithms easy before worrying about this kind of issue.

--
:wq

In reply to Re: Perl speed VS. other languages by FoxtrotUniform
in thread Perl speed VS. other languages by tretin

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.