Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Perl vs. Python: Looking at the Code

by rje (Deacon)
on Sep 01, 2005 at 19:09 UTC ( [id://488466]=note: print w/replies, xml ) Need Help??


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

This is an old, old thread, but I feel like throwing in two cents, since I've recently been seeing how Python feels. And it feels strange. Not necessarily bad, just strange.

First, it doesn't give you many hypotenuses. Don't get me wrong, there are some nice shorthands, to be sure -- the slice syntax is cool and could be borrowed -- and its object-orientation is politically correct and (more importantly) doesn't look bizarre. And its treatment of Strings as Lists is, in the long view, probably correct. However, I've seen no other syntax benefit so far over Perl, and in fact that pales in comparison the cool shortcuts that Perl gives for free. And the CPAN sweatshop, where you can Find It's Already Been Done For You.

Moreover, there are some things that would be sorely missed if I had to use Python for some jobs. In particular, it feels too far removed from closures. This is purely a side-effect of not using explicit block delimiters, I suspect. The lack of Perl's concise range operator is painful to me. There's also a slight whiff of Java about when I code in Python. And any niceness in syntax is nullified by some very strange things which will, due to frequent usage, bother me all the time, such as the trailing comma on the print statement! What's the problem here? Why can't you use \n, or at least bow to Java and have print() vs println()?

And, though I haven't delved deeply into it, variable interpolation in strings looks painful in Python. Isn't the C language 30 years old now?

Next, there are a couple things I'm waiting for in Perl6. In particular, a more sensible way of declaring, creating, and handling objects and object methods. Python captured the essence of quiet object-orientation. And I'm all for the loose mixin-like behavior of Perl6 (and Ruby) too. And, already explicit is the ability to change Perl to what you want it to be via predeclaration. All is fair if you predeclare is my mantra. (You can even do that now in Perl5 with source filtering.) If I want to steal some hacks from Arc then I can predeclare them in my Perl modules. This is a big win.

To sum up, basic Python is just a hybrid Perl-Java-LISP language which appears to bring little that is new. And while I love Perl, respect Java, and like LISP, and think emulating them to some degree is admirable and even worthwhile, I still get the feeling that I'd rather have the "value" (if that can be assessed) of Java and LISP without sacrificing Perl.

I think it's time to put Python back on the shelf, and see what Ruby feels like.
  • Comment on Re: Perl vs. Python: Looking at the Code

Replies are listed 'Best First'.
Re^2: Perl vs. Python: Looking at the Code
by MonkOfAnotherSect (Sexton) on Sep 02, 2005 at 04:53 UTC
    *delurk* This really isn't the place for anything vaguely indepth, but:

    There's also a slight whiff of Java about when I code in Python
    If your Python feels like Java you're probably not using it correctly - I suspect that you're using range() for indexing. If you're using range(len(foo)) use enumerate() instead. I also suspect you haven't been using generators, iterators, and listcomps as often as you should have been.

    In particular, it feels too far removed from closures.
    Hmm... Python has closures, just not anonymous ones (though because strings and numbers are immutable and one has to store variables in a mutable object (list or dict), classes - or in some cases generators - may be preferred).

    Regarding print, if you're using lots of prints terminating in commas, your code probably isn't very Pythonic...(trailing comma is likely to be removed in 3.0)

    Variable interpolation is as painful as C's (though you can use string.template for interpolation closer to Perl's)

    Anyway, have fun with Ruby ;-) *relurk*

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-04-16 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found