Linked by Thom Holwerda on Fri 10th Sep 2010 14:59 UTC
General Development Python programmers shouldn't get too smug. While many people agree that Python is designed in a way that makes it a highly readable language, there can still be problems with legacy, untested Python code too. Porting legacy Perl to Python can be a daunting task. In this article, learn some of the theory behind dealing with legacy code, including what not to do.
Thread beginning with comment 440336
To read all comments associated with this story, please click here.
Why would I want to do it?
by reez on Fri 10th Sep 2010 16:38 UTC
reez
Member since:
2006-06-28

I don't get it. Why would I want to do this?

Perl meanwhile became pretty nice again with all these Modern Perl stuff. I dropped Python and Ruby again.

I can see only two language that could compete with it in future. Falcon and Perl 6.

However, bot of them and especially the later one are still to knew.

Perl isn't perfect, but they had plenty of time to fix everything and when it comes to maturity the other simply can't compete. Yeah, OO has been a big problem, but Moose has been there for a while now, if you don't like the old way.

I just can't see an area where for example Python would be better. I mean I've tried it and the only things I can see is that it uses indention and giving me a smaller number of "ways to do it". If I wanted to do it in that way I would simply do it that way. Readability? It's not different from any other programming language. Either you write easy to understand, readable code or hard to understand non-readable code. Everyone of us has seen good and bad Python code I guess.

Yeah, it may be off topic, but I always wondered about that. I mean there have already been new programming languages and it is good to know more than one, but why would I do that switch?

Does Perl simply have an image problem or do I miss something?

Reply Score: 5

Bill Shooter of Bul Member since:
2006-07-14

Yeah, readability might be worth it, IMHO.

You can write elegant, easy to read code in perl, though that is the exception more than the rule. With Python readable code is re rule, rather than the exception.


Perl's big, huge advantage, is that its installed on just about every *nix server.

Reply Parent Score: 3

sreque Member since:
2010-09-10

We managed to compile Python 2.6 on an AIX 5.2 server without incident. Perl does have an advantage here, but it's only really an advantage when you are distributing scripts to customers that have no interest in installing Python on their servers, and I believe this case is very rare.

Reply Parent Score: 1

ebasconp Member since:
2006-05-09

I know that everything is about tastes and likes, but I never did find Python code readable (Perl neither). I actually find C++/Java/C# and that family far more readable.

Reply Parent Score: 2

RE: Why would I want to do it?
by sreque on Fri 10th Sep 2010 17:54 in reply to "Why would I want to do it?"
sreque Member since:
2010-09-10

Here's a few areas where Python excels over out-of-the-box Perl:

function calling conventions
error handling of built-in data types, functions, and language features
exceptions and stacktraces
metaprogramming
object system
variety of implementations
grammar and overall language complexity (affects tool creation)
concept of iterators and for comprehensions
complexity of references
handling of built-in versus user-created data types
threading
package/module system
overall consistency of features
execution model
file handling (Typeglobs, variable references, and OO wrappers! Oh my!)

Many of Perl's weaknesses as listed above can be fixed to at least a certain extent by downloading a bunch of CPAN modules that basically modify the language (see the perl5i CPAN module for a good example). However, why bother going through such a huge effort to fix Perl when you can just use a better designed language? Plus, you have to get your team to agree to use all of those modules, and in my experience people who use Perl are quite comfortable with the default language. With Python, everyone starts out on a much higher and more stable ground.

Edited 2010-09-10 18:01 UTC

Reply Parent Score: 3

sigzero Member since:
2006-01-03

You are really trying to say that Pythons package/module system excels over Perl? Really?

Most of those are pure FUD.

Reply Parent Score: 4

google_ninja Member since:
2006-02-05

I would _highly_ recommend learning a language before making sweeping statements like this. You really make yourself look like a moron when most of what you say is just flat out wrong. (perl actually does almost all of those things). That being said, I sort of wanted to comment on this

Many of Perl's weaknesses as listed above can be fixed to at least a certain extent by downloading a bunch of CPAN modules that basically modify the language (see the perl5i CPAN module for a good example).


A powerful language is one that can redefine itself to meet its needs. If you have that, you can just release a small core and let libraries define all the fancy language features people like. The neat thing about this is that it lets the language move way faster, since cool language features are often created by people who have a good idea, but aren't interested in hacking on c based VMs. There is a time and a place for that sort of thing, and when you are used to it, languages that don't let you redefine themselves start feeling cumbersome and irritating when that time comes, and you are forced to implement something that could have been done in a much more elegant fashion.

Now, all of that is my opinion, as someone who absolutely loves languages like perl, and ruby, and LISP. I know that not everyone thinks the same way, but a great many really smart people do. Hopefully this is a bit of a window into how the "other side of the fence" sees this sort of thing.

Reply Parent Score: 2

pshangov Member since:
2010-09-11

Many of Perl's weaknesses as listed above can be fixed to at least a certain extent by downloading a bunch of CPAN modules that basically modify the language


Modern Perl is ALL about CPAN. The core language distribution has been purposefully kept minimal and it is on CPAN where evolution takes place. In a similar vein key libraries (such as Catalyst) are purposefully kept minimal, with most goodies available as individual modules to be installed separately. A good Perl programmer is nowadays a programmer who knows her way around CPAN. This is an approach that is indeed harder at the start, but immensely more powerful in the long run.

Reply Parent Score: 2

modmans2ndcoming Member since:
2005-11-09

you forgot "trim" functions

Reply Parent Score: 2

sorpigal Member since:
2005-11-02

All of these either exist in Perl, too, or don't aid the point: Maintainability.

Iterators and for comprehension are sweet sauce, sure, but once I have a stack of perl code that doesn't use them and works, what exactly is my motivation for porting to python?

A variety of implementations is nice, but does it *really matter* that I there's "only" one source base for perl? I mean, it's open source! It's not like there's a portability problem when the perl interpreter is concerned, it runs everywhere.

I could go on and on.

If you're *starting a new project* then some of your arguments are useful, but we're maintaining code in this article.

Although, in fact, even when starting a new project I would, personally, be prepared to defend Perl's advantages. I've seen far, far more cases, for example, where an interpreter point upgrade breaks python programs. But we

Reply Parent Score: 2

RE: Why would I want to do it?
by Soulbender on Sat 11th Sep 2010 04:31 in reply to "Why would I want to do it?"
Soulbender Member since:
2005-08-18

I just can't see an area where for example Python would be better.


Funny that, cuz I can't see any areas where Perl would be better.

Does Perl simply have an image problem or do I miss something?


Perl tends to encourage unreadable code, what with all the regex going on.

But hey, if you liker Perl go ahead and use it.

Reply Parent Score: 2

modmans2ndcoming Member since:
2005-11-09

uhh... regex encourages poor readability? What planet are you from? Apparently one that does not see the use of a regular expression.

Reply Parent Score: 2

bitwelder Member since:
2010-04-27

Perl tends to encourage unreadable code, what with all the regex going on.


As it has been said before, it's matter of taste, but do you really think that a long multiline if-then-elseif-elseif-godknowswhat-else block is more readable than a compact regex?
If nothing else, with the regexes you can use all those saved lines for a comment in plain English (or whatever if your native human language) ;)

Reply Parent Score: 1

RE: Why would I want to do it?
by trenchsol on Sat 11th Sep 2010 14:27 in reply to "Why would I want to do it?"
trenchsol Member since:
2006-12-07

Perl isn't for everyone. Some people never feel comfortable with Perl. It is quite different from other languages. I am one of those people. Couple of years ago I've replaced parts of old Majordomo 1.9x MLM with my own Perl code, and it worked, but I don't think I've really learned the language....

In fact, I think that people should not try to use Perl code if they are not confident in their Perl skills. It is better for them to write their own modules from scratch and stay away from Perl completely.

Python is much more, well, mainstream, easier to learn, and, majority of people would say that the code is easier to maintain.

Reply Parent Score: 2

modmans2ndcoming Member since:
2005-11-09

how is python more mainstream than perl?

Reply Parent Score: 2