Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Perl and Java comparison

by dicty (Sexton)
on Feb 25, 2013 at 01:49 UTC ( [id://1020442]=perlquestion: print w/replies, xml ) Need Help??

dicty has asked for the wisdom of the Perl Monks concerning the following question:

Is Perl slower than Java?

What are the differences between Perl and Java as programming languages? The strengths and weaknesses?

Thanks,

Dicty

Replies are listed 'Best First'.
Re: Perl and Java comparison
by wazoox (Prior) on Feb 25, 2013 at 08:25 UTC

    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.

      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
Re: Perl and Java comparison
by Khen1950fx (Canon) on Feb 25, 2013 at 02:37 UTC
      The "Programming Republic of Perl" logo on that page is serious fun.

      When you're finished with your pasty-hands little coffee-break and you've got serious work to do ... Perl has callouses on its hands.
Re: Perl and Java comparison
by sundialsvc4 (Abbot) on Feb 25, 2013 at 14:03 UTC

    Subjective comparisons, or broad-brushed ones like “X is slower than Y,” simply use too broad and too vague of a brush.   A programming language is a tool, and each of them is designed by someone with something-in-particular in mind.   Thus, each language champions certain things at the expense of certain others, just as a wrench is not-so-good for driving a nail although it can be done.   “Versus” comparisons frankly aren’t worth much in practice.

    “Speed,” especially in a modern-day program, has mostly to do with algorithm.   Which is why, in the tiny but important book, “The Elements of Programming Style,” we read this maxim:

    Don’t “diddle” a program to make it faster:   find a better algorithm.”

    But “speed” also has to do with how rapidly a particular set of programmers can accomplish the work, reliably and completely, and how well their work-product will integrate with everything else that surrounds it.   Which is why, say, if you’re writing a program for the Android, you’re probably gonna do it in Java.

Re: Perl and Java comparison (faq)
by Anonymous Monk on Feb 25, 2013 at 02:50 UTC

    :) your username is dicty, you know how to find FAQ :D

    Thanks, I'm here all week

      I'm a biologist. Dicty is an organism that I studied before. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1020442]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-03-28 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found