Slashdot Mirror


Perl vs. Python: A Culture Comparison

davemabe writes "Every programmer has a favorite scripting language. Here is a well written article by Jon Udell from byte.com detailing the differences between Perl and Python, their cultures, OOP, database access, philosophies, and which one will gain the most converts in the future. Very interesting reading on an almost religious debate. "

6 of 351 comments (clear)

  1. Natural Languages and P--- Languages by Lulu+of+the+Lotus-Ea · · Score: 5

    Re: Jon Udell's: "A Perl Hacker in the Land of Python" (http://www.byte.com/feature/BYT20000201S0001)

    Well, since someone else mentined it, here's a reaction I had to an
    email conversation where the Udell URL was cited. Take it or leave
    it... but I finally pinned down what I think is wrong with Wall's
    initially rather intriguing 'philosophy':

    You know in Perl the motto is "there is more than one way to do it".
    Larry Wall takes this by way of a linguistics background, and wants
    to make Perl resemble a natural language. In contrast--at least at a
    syntactic level--Python has fairly clear rules about what something
    *has* to look like, and there tends to be a high degree of
    orthogonality (which Wall vehemently eschews). There were some
    remarks like this in the article. (Obviously, in terms of semantics,
    large-scale design, and algorithms, there are many ways to do a thing
    in any language).

    I think Perl succeeds in what it is trying to do. For that reason,
    it really does often look like a "write-only" language. You can
    easily express your own "thoughts" fluidly and naturally... the
    problem is that they are then as difficult to unpack later as a poem
    or a complex philosophical sentence (good uses of natural language).

    The thing that Wall &gang seem to miss is the distinct registers of
    natural language. The whole thing is very rich in expressivity, and
    highly non-orthogonal. But that is absolutely *NOT* the case when it
    comes to specialized areas of natural language where clarity and
    precision are at a premium. I *WANT* air-traffic controllers to
    speak in a highly structured, syntactically and lexically limited,
    and stereotypical fashion! I really *DO NOT* want them to use free
    verse! To a somewhat lesser extent, I also want programming specs or
    technical documentation to follow a rather rigid pattern. When I
    look in the help file, it makes my life a lot easier if the list of
    parameters to a function are always described under the same heading,
    with a consistent and fairly small subset of English words, and with
    an attention to consistent whitespace, layout and special characters.

    The moral is that Perl is a great language for *implementing*
    haiku... but Python is rather better at implementing functional
    specs.

    Yours, Lulu...

    1. Re:Natural Languages and P--- Languages by Master+of+Kode+Fu · · Score: 5
      I *WANT* air-traffic controllers to speak in a highly structured, syntactically and lexically limited, and stereotypical fashion! I really *DO NOT* want them to use free verse!

      Oh, you asked for it now...

      Haiku
      JFK Junior
      Angle is too steep, pull up
      Shit, call the coast guard

      The Love Song of J. Alfred Pilot
      Let us go then, flight 355
      The 747 looks at the stretching sky
      Like a patient etherised upon a table...

  2. Of Zope, whitespace and style by ajs · · Score: 4
    I'm a Perl guy (note the sig), but this article really pushed me in my long-standing desire to learn more about Python.

    Zope sounded interesting, but I'm also checking out Mason, a Perl-based system that is tied into mod_perl. mod_perl was perl's six or seventh killer application (and I mean application as in applying a tool to a job, not as in a packaged program). First came the power of Perl regex for text processing. Then CGI (remember CGI was pretty much born in Perl). Then came LWP, and a splash was heard round the world. How many robots and spiders are written in anything else?

    Perl is slowing, though. There is a consolidation and honing of features that needs to take place, and perl resists that. In some ways, this makes me long for something like Python, but I've actually been thinking of writing a Perl variant that accomplishes some of the same goals, but aimed more at large-scale programming in performance-oriented environments. I see the main benefits of a new language design being:

    1. Can pick and choose the "best of" Perl.
    2. Some odd Perl tics (e.g. bareword IO handles) can be dropped.
    3. Byte and native compilation of modules and programs would be a primary goal. I won't be happy with Perl byte-compilation until everything in the library can be byte-compiled and used from non-byte-compiled programs. But, there are some very compelling reasons not to re-tool Perl's core to allow for this (it would break too much).


    I dunno. I'll probably spend a couple of months scoping other languages before making any real investment of time.

    As for whitespace and style issues, I dislike Python's way so much that I've put off learning the language for years. It's just so... FORTRAN. Why, of all things would you, in this day and age, subject people to a DEFINITION of TABS?! Why not enforce variable-naming at the same time?

  3. How holy wars start.... by WhiskeyJack · · Score: 5

    The two monks stand side by side, facing the altar, behind which a graven image of the Great and Benevolent Tux stands with wings half spread as he contemplates the GNU/Path to True Enlightenment Through Open Source. One monk wears a single pearl upon his forehead, glimmering in the flickering light of the altar candles. The other sports a torc in the form of a serpent entwined around his upper arm. The gaze upon the image of Tux placidly, each at inner peace.

    The monk with the pearl breaks the silence: "Good brother, I see your movement grow by leaps and bounds. How is this so?"

    The monk with the serpent replies: "It is our more disciplined coding, brother, which more quickly leads down the One True Path of Enlightenment. Discipline of code leads to discipline of mind and body."

    Pearl: "But what of tailoring the Quest to the individual? Be flexible like water, and in time, even stone will fall before it."

    Serpent: "Be structured like iron, and the stone will fall faster."

    Pearl: "But each mind is different, and should be allowed to find their own path."

    Serpent: "There is but one Path, brother, just many ways to find it. Ours is the quickest and most sure."

    The candles on the altar continue to flicker as the two monks fall into a few moments silent contemplation.

    Pearl: "I am afraid I must disagree."

    Serpent: "So you say, but you know the truth in your heart. Did not your order adopt the doctrine of OOP despite the conflicts with your order's earlier, strictly procedural ways?"

    Pearl: "OOP is just one path of many."

    Serpent: "It is the soul of the Way."

    Pearl: "And so you seek to challenge the longstanding authority of the Order of the Pearl? We have existed longer, and are closer to the Truth!"

    Serpent: "You wander blind in the mists, poor deluded souls, while the True Way beckons! You can yet change your $PATH."

    Pearl: "You speak heresy! Leave the Holy Temple before the Great and Benevolent Tux smites you!"

    Serpent: "I speak Truth, and you are but too mad to see it! I curse you and your Order! The Way of the Serpent will triumph!"

    And the monk with the serpent turns and stalks out of the Temple, growling, "We will be back, and in numbers! The Temple will be ours!"

    The monk with the pearl watches his counterpart leave, turning back to the altar and shaking his head. "We will be waiting, and the Great and Benevolent Tux is on our side!"

    -- WhiskeyJack, on serious caffeine withdrawal.

  4. Re:Order vs Disorder by glyph · · Score: 4
    Since we seem to be resorting to the arguement by authority, this is from someone with extensive experience with both perl and python. I am writing a large application in python, and I'm very pleased with it, and I've written several large applications in perl in the past.
    What? Because Python forces you to a strict coding style doesn't mean that your code is "correct". It's still possible to write a bad algorithm in Python, just as it is in Perl.
    Yes, you're correct. It's also possible to write correct, clean, fast programs in x86 assembler. One could even argue that it is equally possible to write everything directly to ELF binary format. -- decent hex-editors exist, and the format is well defined. However, the whole point of language design is to encourage certain practices, not to make them possible. Python encourages writing clean, consistent code. This makes it easier to deal with. If your code is formatted in a very specific style and written consistently, it's more likely that it will be correct, although it's not garuanteed.
    Perhaps you should actually point out some limitations of Perl's OOP. Maybe you could also explain what this has to do with your own code quality.

    $x->{'y'} versus x.y -- and let's not forget about x.__class__=mypackage.MyClass. Can you even do the latter in perl?

    The distinction seems pretty clear to me... perl's class / package syntax is MUCH obviously cruftier. If you think that it's not ... well, then use perl for OOP. We disagree.

    What are you talking about? Sure it's possible to write Perl code on one line, just as in many other languages. Unless you're an idiot, or purposefully writing obfuscated code, it's generally not done. I'm sick of all these comments complaining about how hard Perl code is to read. Providing that:
    a) you actually know the language, and
    b) the code was written by someone who actually knows the language
    You should have zero problems with readability. Remarkably enough, the above applies for nearly every other programming language.
    Have you ever tried to read befunge, or brainf***? I know these languages, and this is certainly NOT true for them. Perl also makes heavy use of punctuation marks to mean things which are not only not immediately obvious, they can be confusing. In fact, a quote from Larry Wall himself is "admittedly, readability suffers..."

    Perl is not as readable as python. If you don't have any trouble reading perl, that's anecdotal evidence... there is a statistically significant number of people who don't have any problems -- and in fact, enjoy -- reading python (read the python mailinglists, or c.l.python, or www.python.org, or #python on IRC... I've been to the perl equivalents, and I've never seen them advertising readability or maintainability), because it was designed to encourage that. This doesn't mean perl is worthless: it's a language feature of python to be consistent and easy to read. It is a language feature of perl to be terse and easy to write.

    Finally, consider this python statement: x=['a','b',{'c':'d','e':['f','g']},['h',['i','j']] ]. I admit that perhaps I'm not the swiftest perl programmer ever, but it is certainly not that easy to make a data structure which is a list of strings, hashes of strings and lists, and lists of lists in perl. The syntax gets really hideous and doesn't mean what it looks like it should. (I can't even come up with a way to write that in perl on they short notice required for posting this comment: perhaps a better perl hacker than I can elucidate..)

    --
    Glyph Lefkowitz - Project leader, Twisted Matrix Labs
    Writer, Programmer - Not a member of the TSU
  5. Re:Asbestos Underwear Anyone? by Industrial+Disease · · Score: 4

    You know, I've never understood why advocates of a language whose motto is, "There's more than one way to do it" take such exception to those who choose to do it in another way.

    --
    Weblogging Considered Harmful: