For a course on genetic analysis I was required to learn Perl (5). I now spend a week with two books and must say that not only did all my prejudices against Perl come true, it is even worse than I imagined. Where all C-like programming languages go one way, Perl goes multiple different ways depending on the context. Following is a non-comprehensive list of all the WTFs I have encountered so far.
my $a = qw(a b c); print "$a\n"; # c - last element my ($b) = qw(a b c); print "$b\n"; # a - first element my @c = qw(a b c); print "$c\n"; # nothing‽ print "@c\n"; # a b c - all elements my $d = @c; print "$d\n"; # 3 - the length‽ print length @c; # 1 - I don't even…
Most of these make very little sense. But most of all, why the fuck do I have to evaluate an array in scalar context to get its length? Dammit Perl, just provide a proper
length function like any other high-level language. Infact, most of the above are a violation of any reasonable type system. Why even have different variable types, if it does not provide any kind of safety?
Perl does provide some kind of safety with the
use strict and
use warnings primitives. If you take the time to implement warnings, why would you not activate them by default? Especially, since it is easy to get things wrong in Perl.
I am OK with learning Perl for this course, but I will definitely need a shower afterwards.