Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: Perl vs. Python: Looking at the Code

by Maestro_007 (Hermit)
on Apr 03, 2002 at 17:29 UTC ( #156361=note: print w/replies, xml ) Need Help??

in reply to Perl vs. Python: Looking at the Code

I'm currently working in an office full of Perl junkies who have to use Python (actually Jython) because of the reasons you cited. It was a bit painful at first, but the language is fairly well documented and easy to learn.

One problem I have with it is the lack of CPAN. I think there's no underestimating its value. We are constantly running around trying to get modules or write our own. Python (especially Jython) hasn't reached the state yet where you can do just about anything, so frankly it's a pain to use.

Is the syntax cleaner? I have no idea. When I was learning Perl the sigils were only a little confusing. Now they come naturally, so I don't know. It just seems to me like grammatical inflection, no less natural than conjugating verbs. Initially with Perl you spend lots of time getting used to it. In Python, there's no up front cost, but a constant cost when you have to look up the first use (notice I didn't say declaration... there isn't a use strict mode that makes you declare them) of any variable you see.

The biggest problem I have with Python, though, is the attitude it has against messy syntax. I know that may seem weird, but I like the fact that have multiple options for doing the same thing. In talking to our more Python-oriented guys, that seems to directly offend them. To me, computer languages should be an attempt to map to human problems. Larry's 3rd State of the Onion was all about this concept. Trying to clean up the language to mask it may not be the most effecient use of our time.

On the other hand, take a look at the 1996 article Perl vs. Python by Tom Christiansen. It's a bit out-dated, but it makes good points. The most salient for my company's application (besides Java compatibility) being its intrinsic object-orientedness. Perl's object model is powerful and allows many good things, but it's not as easy to learn as Python's. You have to be very good at Perl to be able to use Perl objects. You can use objects in Python within 24 hours of starting to learn it.

All in all I miss Perl terribly and still use it in my personal projects, but so far Python isn't stealing my sheep, robbing my house, or giving me shooting pains up and down my spine, so we'll keep using it. It's certainly better than that Barbarian horde we tried to hire to work on this part of the application (sorry, inside joke).


p.s. Want a laugh? Try to imagine a Python Golf Challenge!

Update: I knew I had a specific example of "cool" Python syntax that I did want to share:

if listElement in aList: ... do stuff ...

In Perl you gotta do this with grep (or something else like that). It's pretty.

And another thing, this book saved our lives on this project. It's very objective, doesn't get at all religious, and has a very informative feel to it. "If you want to do this in Perl, here it is in Python." It has an alphabetical list of functions and their equivalents. I can't recommend it higher. It does not seek to answer "which is better", it just recognizes that this problem exists and shows how to cope.

Replies are listed 'Best First'.
Re: Re: Perl vs. Python: Looking at the Code
by buckaduck (Chaplain) on Apr 03, 2002 at 18:56 UTC
    if listElement in aList: ... do stuff ...
    In Perl you gotta do this with grep (or something else like that).

    Although we can apparently look forward to the following constructs in Perl 6 (if I read this correctly):

    # Do stuff if $list_element is in @a_list if ($list_element =~ @a_list) { ... do stuff ... } # ... OR ... # Loop through a bunch of list elements foreach @list_elements { # Do stuff if the current element is in @a_list when @a_list { ... do stuff ... } # If not in @a_list, what about @other_list ? when @other_list { ... do stuff ... } }


Re: Re: Perl vs. Python: Looking at the Code
by Anonymous Monk on Apr 04, 2002 at 00:10 UTC
    Is a language that encourages cute ways to state bad algorithms better or worse?

    The syntax is pretty. But in some ways it is nicer that Perl encourages you to think about whether there is a more scalable way to do it. (Use a hash!) And if you want the idiom, it is easy enough to create in Perl.

Re: Re: Perl vs. Python: Looking at the Code
by shotgunefx (Parson) on Apr 04, 2002 at 11:17 UTC

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://156361]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (7)
As of 2023-02-08 11:36 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (42 votes). Check out past polls.