Good argument.

Two minutes to code, and even though it take more than three time as long to 
run, does this application require the faster runtime?

Unless you are working on a MUCH bigger data set, or this would be called TONS 
of times on a truly busy server, I would concur that perl is the right tool for 
this particular job (and many like it).


$ time ./strrev.pl < ./words > /dev/null  # perl version listed below

real    0m0.180s
user   0m0.171s
sys     0m0.009s

$ time ./strrev ./words > /dev/null   # C version

real    0m0.048s
user   0m0.045s
sys     0m0.003s

As for java: no clue.  I suspect in this task it would not do as well as even 
the perl, as the JIT won't shine until it does it a lot more for a lot longer.  
Java does tend to suck for doing many small, quick tasks like this (not talking 
about threaded apps that stick around, etc).  Not it's wheelhouse.  Which 
brings up the idea that benchmarks only work for the specifics they are setup 
for, aka, everyone can do benchmarks that show how a particular language will 
shine.


On May 2, 2013, at 8:03 AM, Barry Roberts wrote:

> On Thu, May 2, 2013 at 7:25 AM, Sasha Pachev <[email protected]> wrote:
>> Levi, beat this in Haskell. Barry, Dale, beat this in Java.
> 
> Sorry, you'll have to find someone with more time on their hands and
> who actually cares how fast Java can read, reverse, and print lines of
> text.
> 
> But I can tell you I would much rather write:
> 
> #!/usr/bin/perl
> 
> while ($curr_line = <STDIN>) {
>    print scalar reverse($currr_line);
> }
> 
> I haven't run that, but I'm pretty sure it will work and that was just
> off the top of my head in 2 minutes. I'm no perl expert, but I do try
> to use the right tool for the job.
> 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to