Perl v. Java


From a truly ill-considered Ask Slashdot question came this pearl of wisdom. A former (award winning!) Java hacker confesses his adulterous thoughts for Our Favorite Language. I’d like to pick up on a few of his points and perhaps add a bit of my own.

  • Unicode: it’s a sore spot of Perl, but seems to be hunky-dory for java. I lay the blame for Perl’s developmental problems here on DWIM. As Perl coders, we’ve come to expect Perl to handle simple (and not so simple) string manipulation without that much handholding from us. I suspect that this bit of Sloth is biting the ‘porters. Certainly, the unicode issue is preventing Perl from being a first class XML processing language (no XS cheating here).
  • Perl’s threading system is still developing, but java’s model seems to be working fine. Of course, Perl’s forking model is probably better and easier to use than java’s (cross-platform forking is difficult to guarentee). I say tit-for-tat on threading/forking here.
  • Dedicated IDEs are bullshit. There, I said it. Coders shouldn’t handle their code with the tongs of an IDE, like some poor MS Word shlub. If the java folks have more IDEs than Perl People, good on ‘em.
  • ALL PRAISE CPAN! Perl was years ahead of MOST other languages here and continues to put java to shame. CPAN is not only an FTP archive, it’s damn protocol to download and install libraries! In your face, JAR!
  • Elegance is something for which python and java are praised and for which Perl is found wanting. Clearly, I don’t get the ‘elegance’ argument and I never have. If ‘elegance’ means fewer characters typed during coding, Perl wins for most applications. Consider perl one-liners, the inclusion of perl hashes, regexes, etc. Perl delivers the promises of ‘less typing’. Is elegence the lack of ‘weird characters?’ It may be, but Perl’s syntax acts like a road sign to tell the maintain what’s going on. Sigils (those funny characters preceding variable names) are not a misfeature — they are essential to maintaining a Perl program. You always know what to expect from a variable with a sigil. Without them, the reader (and coder!) needs to find the original declaration of the variable to figure out what it is. I hate that. Is elegance the object model of a language? Python and Perl’s object model isn’t terribly different. Shocked? Don’t be. The difference between python and Perl objects is that python has a object type, where perl blesses variable data. Java and Perl object models are very different. Java’s single inherentence (which is a Good Thing) and object data protection (which is a Useless Thing) definitely come from the C++ crowd.
  • You always get the source code with every Perl script and library. This makes it simpler to debug programs in Perl because you can always step through almost all of the code, including the libraries.
  • Readability. Perhaps this is meant to go under ‘elegance,’ but I think this is a different issue. All languages can be obfuscated. It’s not the language designer’s perview to make you code clearly. Any claim a language makes to being inherently cleaner to code in (I’m looking at you, Java and python) is naive. I don’t expect a java programmer to maintain a Perl program, just as I don’t expect a Perl programmer to maintain a java program. In fact, that’s why I’m not an editor for a Japanese magazine — I have no facility for the language. Does that mean Japanese is inferior to English?

[Original post and comments.]