Python vs. the Perl programming language
A language that doesn't have everything is actually easier to program in than some that do. (Dennis M. Ritchie)
One of the best pieces I've seen on the subject of Python vs. Perl is Eric Raymond's piece in the Linux Journal.
Language choice is a relatively subjective, almost religious issue. These remarks are the opinion of the author after a few weeks spent talking with people who have used both Perl and Python, and reading comp.lang.python, and writing a few small Python applications.
One of the best student systems programmers to come through New Mexico Tech recently is my colleague Mike Fisk. When he first learned Perl, he evangelized for it heavily. A year or so later I asked him if he still loved Perl. He replied that Perl was fine up to a hundred lines or so, but beyond that he sort of ``hit a wall,'' as he put it, and it got hard to manage the complexity. He now thought Python was a much better language for readability, maintainability, and modifiability.
This attitude is pretty much in accord with what I saw in a long-running ``Perl vs. Python'' thread in comp.lang.python.
Perl tends to be cryptic and hard to read. Of course a good programmer will write more legible code than a bad one, but Perl's power is reflected in its complex syntax and many operator symbols, while Python has a simple, elegant base language, and the power resides in its library.
Two things about Perl that especially irritate me are the necessity of using a $ before every variable reference, and the convention that $_ is the ``default operand'' whose meaning depends on the context.
Python was designed from the start as an object-oriented language. Perl 5 has some o-o features added on, but it looks to me like an awkward retrofit. Python has well-implemented o-o features for multiple inheritance, polymorphism, and encapsulation.
In summary, it seems to me that Python dominates Perl in most applications except for fairly short shell-script sorts of applications, and there they are roughly comparable.
My good friend Danny Quist was one of the sharpest students to go through the excellent CS program here in the last few years. He sent me this confession:
This has been gnawing at my soul for quite some time, and now it's confession time. A couple of weeks ago I started programming python. It's an excellent language, I love it. It's very clean and the built-in datatypes are great. It has a very good object implementation and my code is better because of it. When you want to do abstract datatypes in perl it's nothing but trouble. Python won my heart with its flexibility in that regard. You were right, I was wrong.
My former professor John Slimick, a Stanford graduate from the 1960s, was my principal CS guru when I was in college. He is still teaching at a Pitt branch campus. Some of his early thoughts on Python vs. Perl:
``I'm just finishing up a one credit on perl, and I'm not happy. I had the misfortune to be heard saying the perl was a write-only language, but that pretty much how I feel. I have never had such an intense feeling that perl is the language where:
Possible perl programmer: "I really need something like an inversion operator (like box with - and two dots in APL)."
perl spokesman: "Hey, Larry -- this guy needs a general matrix inversion operator."
(muffled response from Larry Wall way in the back): "Tell him, for sure, version 7. Is there anything else he needs?"
``perl certainly looks and feels like the shell languages it came from. And don't get me started on defaults...
``I did have the unusual experience of two students in the perl class competing on who could write a piece of code in the fewest lines. The winner got it down to a single line. (The winner also said that while it is true that perl is unmaintainable, he wouldn't mind getting paid to maintain HIS perl code.)
``The one thing that I have noticed so far in python is that the language seems designed. The little that I've seen so far, apart from __thing__, seems readable, unlike most of perl. I don't feel handicapped by my knowledge of the ALGOL related languages.
``...I was delighted to see apply, map, and lambda. It's about time someone steals from LISP. My opinion is that LISP is probably still the champion of ideas/reserved word.''
John Shipman, email@example.com
Last updated: 2013/02/07 05:55:42 UT