<Religious Zealot Rant>
- Too many different kinds of
variables!? :
There are three
primitive types used in most
Perl programs. They are
scalars,
lists, and
hashes. For you to say that this is confusing boggles my mind. Too many as opposed to what? This is the smallest set of primitives in any language that I use regularly, and while it can lead to other issues, confusion due to abundance is not one of them
- Ugly syntax/ Unmaintainable -
"Any sufficiently advanced technology is virtually indistinguishable from magic."
-
Arthur C. Clarke
Okay, maybe this is not exactly applicable here and I am just dreaming, but of course anything that we are unfamiliar with is totally confusing. When I first tried reading
Linux kernel source, it looked like
assembly language to me. Now it is clearer than English.
How do you justify this "unmaintainablility/write once" nature of Perl with the fact that 85% of
CGI apps on the web are written in Perl? Perl gives you the
freedom to write really ugly, unmaintainable code, sure, more so than any other language in my opinion.
TMTOWTDI, after all. But when people impose
discipline, and write good
Perl code using strict, and when this code is viewed by someone else who is knowledgeable in the ways of Perl, then it is no worse than any other language.
- List versus scalar context:
Perl is GOOD at figuring this out for you (better than any language I know of), but sometimes you get bitten in the ass for not understanding the
API. And the fact is that Perl lets you get a lot done without even knowing that there exists an
API. I would like to see you say that you don't want to know what type of data something is supposed to accept/return with and then try writing ANYTHING useful in
java.
Ignorance of the law is usually not a good defense in computer programming, although Perl is extremely
lenient in this area.
An aside to how this IS a problem is this:
My $foo;
$foo = reverse reverse 'hello';
print $foo;
This prints out 'olleh', even though you would think
that calling reverse twice would return the original word. However, if you read the API spec for 'reverse', you will see that it returns a list when called in list context. So the second reverse is operating in list context, just reversing a one element list and returning it. The left most reverse then reverses this "hello" in scalar context, since it is being assigned to a scalar, $foo.(Fix this by adding a placing 'scalar' in between the reverses to force scalar context) One of the very few cases where you have to read the documentation, as Perl's DWIMer is not utterly perfect.
Conclusion - Sorry if I sounded harsh, it's just that
when someone professes to "dabble" in something and then tear it apart, I have to jump to the defense of one of my favorite tools. I am a
java programmer by profession, although I write a lot of Perl in the course of getting things done. And I am by no means a
guru, so everything
above is simply based upon my experience, and should not be taken as fact/
scripture.
YMMV. Cheers!
</Religious Zealot Rant>