Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Perl or Python?
by sub_chick (Hermit) on Nov 30, 2005 at 13:06 UTC
    I went through this dilemma this past summer when i first decided to take up programming. At first i was biased with python only because it was said to be easier than perl. Then, i saw that what people were saying negative about perl (the fact that there are many ways to write up the code) came out to be a plus in the long run because then you can develop your own style and perl is just so many other wonderful things...

      I'm not sure your code design methodology should be the only factor affecting your language choice. If it is really OO that is the deciding factor then Python could be said to be 'more' OO at least until Perl6 arrives(?).

      Not knowing much about Python you may even find other languages like Ruby or Java are even better for OO support.

      Nearly all modern languages will have OO support and generally Perl and Python should both have enough OO for your needs.
Re: Perl or Python?
by Happy-the-monk (Canon) on Nov 30, 2005 at 12:18 UTC

    Ok, I'll bite. What kind of OO-project are you thinking about? And what does "better" imply to you?

    If you are venturing out with Python programmers to do a Python project, chose Python, that's better.
    If you are venturing out with Perl programmers to do a Perl project, chose Perl, that's better then.

    Since you asked this on Perl Monks, did you expect someone would tell you, Python was generally better than Perl?

    Cheers, Sören

Re: Perl or Python?
by ctilmes (Vicar) on Nov 30, 2005 at 12:14 UTC
    Does a car fare better than an airplane if I'm traveling somewhere?

    Seriously though, this is such an open ended question it can't really be answered without more specific information about the project.

    If you have a really good OO Perl programmer who has never used Python, then for some types of projects it is likely Perl would fare well.

Re: Perl or Python?
by Perl Mouse (Chaplain) on Nov 30, 2005 at 12:29 UTC
    Python of course.

    Now, go over to the Python guys to ask why.

    Perl --((8:>*
Re: Perl or Python?
by zentara (Archbishop) on Nov 30, 2005 at 12:34 UTC
    Python is better if you like to hit the tab key.

    I'm not really a human, but I play one on earth. flash japh
      Why, exactly, is a language that requires uniform indentation for statements of a particular block a bad idea? Because it makes it harder to obfuscate?

      Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
      How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

        Try and write a useful python -e one-liner which has nested loops or conditionals and I think you'll have your answer.

        (And as an aside, no the whitespace-as-indentation's not completely without merit but it does straightjacket you in some contexts; besides there's enough other blecherous stuff about Python (admittedly some of which they've actually started to clean up))

        Well, it doesn't even require it - if you want to you can put the entire block on a single line ;-)

        I don't mind Pythons whitespace rules at all. It's not that coding in Python requires any change to the whitespace practises I've been coding with for decades. (Well, except for one minor thing. With my editor, it's slightly easier to close a block using Perl (or C) than in Python. When coding Perl, if I start a line with a closing parenthesis, brace or bracket, it will automatically align it with the line that has the corresponding opening brace - when using Python, I have to use ^D. Same amount of keystrokes, but a lesser used combination than }, so slightly (very, very slightly) more difficult in Python than in Perl. Oh, and there's '%' (vi users will know)).

        Perl --((8:>*

        I don't know...

        However, the question brings to mind the TUTOR language (used on PLATO many years ago and once again available). The language uses commands with arguments. The commands are flush left, up to seven characters long, then tab to column 8 for the arguments. In the course of its life, structured programming features were added -- if, loop, etc.

        unit foo next bar if a > 123 . at 1010 . write a is big... endif calc c <= 0 loop . calc c <= c + 1 outloop c > 10 reloop c < 5 . at 1210 . write c between 5 and 10 endloop

        You could, of course, nest those structures. That made it ugly if you got deep into indentation...especially given that the screen is 32x64. Yeah, uniform indentation is not necessarily a Bad Thing, especially if the alternative is doing without block-like stuff.

        PLATO ran on CDC mainframes such as the Cyber. Some folks are running a Cyber emulator on a high-end Pentium box (with a Mac as the backup) on top of which they are running NOS and PLATO. You can read more about it at


        First off, note that the whitespace silliness isn’t the foremost reason I just can’t like Python, but it sure is a constant irritation. Why?

        When I am rearranging my code, I generally cut and paste sections together as I see fit.

        With Perl, I use Vim’s = command on the entire section and the indentation is magically cleaned up in one fell swoop.

        With Python, I use Vim’s = command on the entire section and have a veritable mess on my hands. No can do. I need to pay close attention and reindent everything immediately upon pasting.

        Basically, the difference is that you can indicate the nesting structure of a piece of code by asserting it with one visible extra character every dozen lines or so and let the computer work out the formatting from that; or you can specify the nesting structure of a piece of code by re-asserting it on every single line with multiple invisible characters and be unable to request any help with it. I thought computers were supposed to automate dronework.

        I shuffle code around often enough that it matters to me: I generally postpone structuring code until I’ve written it and can see which parts do what – what lends itself to extraction into subroutines, whether some functions can be inlined, etc. In a way, I let the code suggest its distribution of responsibilities to me. Perl just lets me be as sloppy as I deem fit. Python doesn’t trust that I’ll be disciplined when it counts.

        That’s a general trend which extends to a lot of other details. In expressive power and conciseness, the languages are neck to neck, but writing Python feels like work.

        Makeshifts last the longest.

        It causes problems when you use a different variation of whitespace than the next person. Say you write this (psedo-Python):

        if mumble \tfoo

        Say the next programmer has their editor set to show tabs as 4 spaces, and uses 4 literal spaces for each indent. They add:

        if mumble \tfoo bar

        Oops! Now a new block has started. This will almost certainly cause a problem at some point, and it will be very difficult to see exactly what the problem is (whitespace problems are like that).

        Good solution: Have coding standards that force all members of your team to have consistent indent settings. Better solution: Don't have your langauge use whitespace for anything more than tokenizing. Preferably not even that, if you can get away with it.

        In any case, I think this is mostly an annoyance, and it does not stop me from using Python or Ruby.

        "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

        It also makes copying and pasting blocks of code from webpages harder.

        (Although programmers never use copy & pasting, right? ;)

        Why, exactly, is a language that requires uniform indentation for statements of a particular block a bad idea? Because it makes it harder to obfuscate?

        Go ask a COBOL programmer the same question about Area A & B ...


        Wait! This isn't a Parachute, this is a Backpack!
Re: Perl or Python?
by swampyankee (Parson) on Nov 30, 2005 at 16:40 UTC

    To be a bit cranky, what do you mean by "fairs [sic] better?". Fewer bugs after release? Better adherence to schedule? If that's the case, the choice of language is less important than the managerial issues of a project: good specifications, and an efficient system to manage the inevitable changes, regular progress reviews, attentive and knowledgable managers, etc.

    If this is for a small project (less than a few thousand sloc), pick the one you like better (if there are multiple participants, vote on it). For a larger project? Just pick one by managerial fiat. While I like Perl better than Python (I'm on Perl Monks), and I think Perl has more available libraries (see CPAN) than Python, I don't think that either (or any) language is The One True Language™; if you like Perl better, pick Perl. If you like Python better, pick Python. If you want absolutely pure, straight-up OO programming, look at (whispering into your ear) Smalltalk, Eiffel, Sather, Simula, etc. (see Survey of Object Oriented Programming Languages).

    I find Python's formatting rules annoying, but that's a trivial reason; I used to write JCL, so I've been sensitized to weird rules for code formatting.


Re: Perl or Python?
by PreferredUserName (Pilgrim) on Nov 30, 2005 at 19:28 UTC
    They fare about the same: both of them have sufficient expressive power to accomodate any design you are likely to come up with.

    I suggest you get a book on OO, write a few OO-heavy baby programs in both languages, and choose whichever one's warts annoy you the least.