Perhaps your time would be better spent becoming a better perl programmer than to learn a new language? :)
Seriously, it's unfair to compare bad perl code that doesn't use common idioms. If you write bad ugly code you've got nobody to blame but yourself.
If it was something I was writing for myself I would use something like this. It's something I probably wouldn't use in production but it's a fairly decent example. The advantage over your example is that the sort comes after the grep, thus avoiding sorting records you are going to reject anyway, the same with quotes.
Yet the author points out that not everyone will appreciate the blocks.. even though the Python variant is using much the same thing, just as an explicit lambda.
In what universe is the Python variant make readable? The variable name is repeated (not very OO like) and there's more syntactic salt and verbosity.
And in reasonably idiomatic recent Python, the whole thing'd be:
#!/usr/bin/env python
import fileinput
import csv
EMAIL, CONTACTME, SKUTITLE = 17, 27, 34
tsl = csv.reader(fileinput.input(), dialect='excel-tab')
for line in sorted([r[SKUTITLE], r[CONTACTME], r[EMAIL]] for r in tsl
if r[CONTACTME] == "1"):
print "\t".join(line)
It's going to be good in any language though, isn't it?
It's nice that he decided to try a couple of new languages that he'd never written any code in before, but what significance does his experience of writing a trivial tool in each really have for other people? The blog post strikes me as a bit like a youtube video of somebody trying out a couple of musical instruments they haven't played before... irrelevant to people who don't know the submitter.
Yes, it is a worthless comparison. This specific application would look almost exactly the same in assembly language, so there is really not much to learn here.
It is interesting to see that "I am switching from Perl to Ruby or Python" was something people blogged about in 2002, however.
Perl's dereferencing semantics are atrocious. I love the language, but figuring out which combination of sigils dereference something can take forever. I'm so very glad they included arrow notation, that's literally saved me hundreds of hours. I've always had the impression that the basic dereferencing ($$r[$SKUTITILE]) semantics were more a function of clever Larry thought he could be than something that was well planned.
If I'm not mistaken, the dereference notation changes again in Perl 6, but I haven't bothered to really check it out until the releases reach a production level.
>>The punctuation and my’s make this harder to read than it should be.
Huh, declaration of variables should remove a typical error at least I do:
foo = X
if ...
foi = Y
..
if foo == X ..
I really don't understand why the strict functionality isn't default in Perl and all other languages.
Also, only total newbies initialize arrays like this:
my @records = ();
Most every time Perl is mentioned, we get an insane amount of trolling. It is quite boring. Now I'm out of jeans, into a good shirt and off for a party, so you have to work on someone else... :-)