Perl is a great language to learn, and I hope you'd remain around on PerlMonks to see the cool things you could do with it. It's usually fast enough, but more importantly, it's highly "optimized" for programmer effort such that you can get more done with minimal coding.

Performance comparisons between two language implementations is hard to get right. You need to know the intricacies of both languages to avoid an apples vs oranges comparison.

Here's a different Perl implementation that runs a lot faster on crappy hardware. Rehashing merlyn's article, I got the following code, which uses core Perl features only, to find all primes <= 3_000_000 (216816 total) in 9 secs:
timethis for 1: 9 wallclock secs ( 7.64 usr + 1.22 sys = 8.86 CPU) +@ 0.11/s (n=1)

This is run on FreeBSD vmware (256MB RAM) on an 8 year-old Athlon XP.

use Benchmark qw(timethis); sub primes { my $upper = shift; return () unless defined($upper); $upper = int(abs($upper)); my $sqrt1 = sqrt($upper) + 1; my $sieve = ""; my @p = (2, 3, 5); my $n; my $iter = sub { if (@p) { $n = shift @p; } else { do { # only ends with 1, 3, 7, or 9 $n += ($n % 10 == 3) ? 4 : 2; } while vec($sieve, $n, 1); } return undef if $n > $upper; if ($n < $sqrt1) { for (my $m = $n**2; $m <= $upper; $m += $n) { vec($sieve, $m, 1) = 1; } } return $n; }; return $iter unless wantarray; my @gather; while (defined(my $x = $iter->())) { push @gather, $x; } return @gather; } timethis -1, sub { printf "count: %d\n", scalar(() = primes(3_000_000) +) };

Update: Added preamble for OP.

In reply to Re: performance of perl vs java by repellent
in thread performance of perl vs java by Anonymous Monk

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.