http://qs321.pair.com?node_id=1020474


in reply to Perl and Java comparison

It depends on your metric, because "faster" can mean different things. Perl is much terser than Java, and hasn't a static type system; therefore it's usually way faster to write the same program in Perl than Java. As programmer's time is way more expensive than computer time, this is usually a significant metric.

Now about execution time: most programs nowadays are IO-bound or network bound. If your program falls into this category, most languages (Java, C, Assembly, Perl, Python, ...) will perform similarly (i.e. none will be 10x faster than the other). Therefore you should choose the language you're the most comfortable with because none is actually much faster. But consider the first paragraph.

Last comes the case when your program is CPU-bound: by this metric, usually Java is faster than Perl. Java generally also provides easier or better tools to parallelize computations.

How do you know if your program is IO bound or CPU bound? if your programs reads vast amounts of data from the disk or network, than it's certainly IO-bound. If your program reads little data, than makes computation on it for hours, it's CPU-bound.

Replies are listed 'Best First'.
Re^2: Perl and Java comparison
by tobyink (Canon) on Feb 25, 2013 at 14:02 UTC

    In the programmer-time versus CPU-time comparison, it's useful to know how many times the program will be executed.

    If the program is a data munging routine that will be written, run once on the test database, and then once on the live database, then never used again, the programmer's time is probably a lot more precious than the execution time.

    But if the program is executed dozens of times each day, by hundreds of users, optimizing the run-time of the program, even at the expense of programmer time seems worthwhile.

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name