Re: Perl losing, unfairly
by jepri (Parson) on Jun 15, 2004 at 04:04 UTC
|
You should definately mail him, but don't get too worked up.
It's just Yet Another Example of someone doing an opinion piece and dressing it up so he doesn't look as clueless as he is. He's assigned weighted scores to qualitative values, he's arbitrarily picked language features to compare, and worst of all, he's presented numeric scores like they actually mean anything at all.
As a 'here's how to do XXX in 20 different languages' it's actually not bad. As a comparison piece, it's clearly a waste of time.
As for Perl coming out on top, have a look at Paul Graham's pieces on good languages.
| [reply] |
Re: Perl losing, unfairly
by perrin (Chancellor) on Jun 15, 2004 at 05:13 UTC
|
The trouble with trying to win a contest based on program length is that it will lead you to write nasty code that reinforces people's opinions about Perl being hard to read. The first things to go in Perl golf are "use strict" and "use warnings", which is not something I want to see when trying to demonstrate that Perl is mature enough to be used for serious projects. (I know, the example given above is entirely reasonable, but "I can make my program shorter" is a slippery slope.) | [reply] |
Write the author
by PodMaster (Abbot) on Jun 15, 2004 at 05:45 UTC
|
You should write the author. That perl -le"" stuff should definetly go.
I wrote him a couple of times already.
PS - This has already been discussed here (i think, maybe just in chatterbox) and on use.perl.org (for sure).
update:
s{-e "/etc/mtab" or exit 1}{exit !-e "/etc/mtab"}
s{-r "/etc/mtab" or exit 1}{exit !-r "/etc/mtab"}
MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" | I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). | ** The third rule of perl club is a statement of fact: pod is sexy. |
| [reply] [d/l] [select] |
|
| [reply] |
Re: Perl losing, unfairly
by dreadpiratepeter (Priest) on Jun 15, 2004 at 12:00 UTC
|
| [reply] |
|
I mailed the author with some issues and have recieved a reply. One part is relevent to what you just said:
i fixed. For example, for
% perl -le 'print $ARGV[0]'
i take the length of
-l print $ARGV[0]
But the fact remains that he has NOT been generous to Perl. In fact the way I read the code hes been ungenerous to perl. Consider all the examples that involve or exit 1 (which is not normal idion to return an error value to the OS in perl, unless that error MUST specifically be 1, any sane programmer would use die,) or the fact that in many of the examples he includes the invocation in the perl examples but not in any of the other examples.
But what really gets me is the File::Find example. His code reads to me the way someone would write it if they deliberately want to disadvantage perl.
use File::Find;
find({ no_chdir => 1,
wanted => sub {
if (($o = $_) =~ s/\.c$/.o/
&& -M $_ <= -M $o) {
print "compiling $_ to $o\n";
system qw(gcc -c -o), $o, $_;
}
} }, '.');
Why the no_chdir here, or the options hash at all?
use File::Find;
find sub {
if (($a = $_) =~ s/\.c$/.o/
&& -M $_ <= -M $a) {
print "compiling $_ to $a\n";
system qw(gcc -c -o), $a, $_;
}
}, '.';
So, by my reading of this once these changes are made Perl wins.
---
demerphq
First they ignore you, then they laugh at you, then they fight you, then you win.
-- Gandhi
| [reply] [d/l] [select] |
|
Actually, I missed that in the File::Find example. In fact either the Perl test (and some others) is invalid or the shell test (and some others) is.
The shell script compiles recursively, and the Perl has a check to avoid compiling recursively. One of them violates the goal of the script
As far as the exit stuff goes, I realized that it could be written better as:
exit !-e "/etc/mtab"
I emailed the author with the exit changes (and reiterated your File::Find findings). Hopefully he will resolve them.
-pete
"Worry is like a rocking chair. It gives you something to do, but it doesn't get you anywhere."
| [reply] [d/l] |
|
|
|
Re: Perl losing, unfairly
by tbone1 (Monsignor) on Jun 15, 2004 at 13:15 UTC
|
| [reply] |
Re: Perl losing, unfairly
by hv (Prior) on Jun 15, 2004 at 11:19 UTC
|
Your example replacements are insufficient, because in those cases the string must be printed with a newline.
For 'print first arg', for example, it should be:
print shift, "\n"
(or maybe:
print "$ARGV[0]\n"
)
giving a length of 17 (or maybe 18), exactly the same as (or maybe more than) the score attributed. In the context of a larger program neither '-l' nor 'shift' would likely be reasonable, so you could say the writer has been generous to perl here.
Hugo | [reply] [d/l] |
|
| [reply] |
Re: Perl losing, unfairly
by zentara (Archbishop) on Jun 15, 2004 at 12:08 UTC
|
I can't believe that bash shell wins this contest. Yeah, sh scripts are handy, but Perl is far more useful, and readable.
I'm not really a human, but I play one on earth.
flash japh
| [reply] |
|
Really, it's combining bash and perl that is great fun. for example:
[me@host]$ more `which whichpm`
#!/bin/sh
perl "-M$1" -le '$_=shift; s|::|/|g; print $INC{"$_.pm"}' "$1"
[me@host]$
Writing 'whichpm' in perl alone would take a fair bit more space.
And everyone knows that I love perl command line switches :-D
------------
:Wq
Not an editor command: Wq
| [reply] [d/l] [select] |
|
$ alias whichpm='perldoc -l'
$ whichpm HTML::Template
/usr/lib/perl5/site_perl/5.8.0/HTML/Template.pm
| [reply] [d/l] [select] |
|
Re: Perl losing, unfairly
by eric256 (Parson) on Jun 15, 2004 at 14:48 UTC
|
Since it states that its realy competetion of script features of programming and perl actualy ties for second falling only a point short of tie for first it looks quite fair. Some of the perl code isn't what you might right, but i'm willing to bet the same holds true for other languages on that list. All in all I think its interesting but I don't think anyone is going to choose what to program in based on that.
| [reply] |
Re: Perl losing, unfairly
by Steve_p (Priest) on Jun 16, 2004 at 02:50 UTC
|
These types of contests cannot be truly done by one individual unless that person is an expert in all the languages tested. We did a head to head at work once, and took the same set of requirements and two of us wrote the programs in two separate languages. First to meet all the requirements won. Trying to have the same programmer do the same thing just doesn't work since their biases and knowledge (or lack thereof) get in the way of the competition being fair. You tend to get the results you wanted in the first place.
| [reply] |
Re: Perl losing, unfairly
by zentara (Archbishop) on Jun 16, 2004 at 12:22 UTC
|
Here is a better wriiten article on bash and perl scripting, which is better rooted in reality. Scripting for Sysadmins
I'm not really a human, but I play one on earth.
flash japh
| [reply] |