What? You know, I'd like to know what the hell is wrong with perl. All I ever hear from you is dislike for real programming languages, and praise for obscure, never-heard-of languages (never seen ruby or O'Caml before you started talking about them).
I've asked you before, but you always dodge. Are you just jealous because you can't grasp perl/C++/whatever or something?
Let's start with Perl:
Code:
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++
$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
This is a valid Perl program. *Yes it is an extreme example, but why in the world does it work? *I also do not like the fact that variable need to be preceded by signs ($'s, @'s, %'s) to denote their type. *This adds to the general obfuscation fo the entire program. *Perl's default variables can also be weird:
Code:
sub write_to_screen
{
*print "$_[0]\n";
}
write_to_screen("Hello");
How does the default variable $_[0] help? *In no way, it just makes the code more obscure to understand. *Consider this Bloobot module:
Code:
use strict;
package Insult;
sub Insult {
* *my ($insultwho) = @_;
* *return unless &::loadPerlModule("Net::Telnet");
* *my $t = new Net::Telnet(Timeout => 3);
* *$t->Net::Telnet::open(Host => "insulthost.colorado.edu", Port => "1695");
* *my $line = $t->Net::Telnet::getline(Timeout => 4);
* *$line = "No luck, $::who" unless (defined $line);
* *if ($insultwho ne $::who) {
*$line =~ s/^\s*You are/$insultwho is/i;
* *}
* *&::pSReply($line);
}
1;
Which insults a given user by fetching an insult on a server. *Here's the same thing in Python:
Code:
def insult(**args):
*"""gets an insult"""
*from telnetlib import Telnet
*connection=Telnet("insulthost.colorado.edu", 1695)
*connection.write("\n")
*text = connection.read_all()
*import string
*who = args["text"]
*print who
*who = who[string.find(who, " ")+1:]
*print who
*who = who[string.find(who, " ")+1:]
*print who
*text = string.replace(text, "You are", who + " is")
*from irclib import Event
*target = args["channel"]
*if args["type"] == "privmsg":
* *from irclib import nm_to_n
* *target=nm_to_n(args["source"])
*result = Event("privmsg", "", target, [ text ])
* * * *return result
This is from Moobot (#moobot on irc.openprojects.net). *I think it's pretty clear that the Python code is much clearer. *Something I haven't personnally seen, but heard a lot is that Perl's OO model is the crappiest thing one can find. *But I haven't seen it, so I won't comment. *Also, Eric Raymond explains why he likes Python better than Perl. *As a recognized advocate of the Open Source movement as well as a very good computer hacker, I think his opinion isn't really all subjective.
Bookmarks