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 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 and VisualStudio .NET 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 still lets you know what's going on, it just says it concisely. And Perl 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.