Flutterby™! Perl vs Java 2003-03-17 18:11:31.131806+00

Next unread comment / Catchup all unread comments User Account Info | Logout | XML/Pilot/etc versions | Long version (with comments) | Weblog archives | Site Map | | Browse Topics

Perl vs Java

2003-03-17 18:11:31.131806+00 by Dan Lyke / 6 comments

Rafe Colburn has an interesting Perl versus Java comparison, focusing on the philosophical differences between the approaches the two languages take. He illustrates with some code from Blosxom which at first glance seems fairly obscure. He presents a Java[Wiki] version and says:

Clearly the Java code is much more readable, and that's why I like it from a maintainability perspective. That said, if you're really up to speed on your Perl, it's amazing the sorts of things you can compress down into one amazingly byzantine looking line of code.

I differ. Read through those 12 lines of Java) code. Take the time with "perl -le 'print ...'" to figure out what the one line of Perl code does.

Now, imagine maintaining a huge system. You non-programmers think of it as trying to organize a large book. Realize that this is an idiom you're likely to see a few times in this book. Even though the first time through it takes twice as long to understand that phrase, in subsequent passes through the text you can grasp the meaning of the code in one line. The Java equivalent would be like reading a book that said "converted from one language to another" rather than "translated" every time the topic came up.

Dave Winer goes further in his link to Rafe's screed and says:

If you use an outliner to edit your source code, his multi-line Java example shrinks down to one line, just like his Perl example.

I think this is untrue too. Emacs[Wiki] and VisualStudio .NET[Wiki] both have code-folding in them. We can quibble over whether those are true "outliner"s, but the outliner hides the functionality: "There's a 'for' loop here, but I don't know what's inside it." Perl[Wiki] still lets you know what's going on, it just says it concisely. And Perl[Wiki] offers you the tools to figure out what's going on fairly simply.

[ related topics: Dave Winer Perl Software Engineering ]


Flutterby™ is a trademark claimed by

Dan Lyke
for the web publications at www.flutterby.com and www.flutterby.net.