by hoodoof · 10y ago · 0 comments
Perl says "there's more than one way to do it"
Python, by contrast, says "There should be one-- and preferably only one --obvious way to do it."
The practical outcome of the Perl philosophy is that Perl code can be extremely varied to get the same thing done and therefore much harder for different programmers to understand and maintain. Python programmers are more likely to quickly understand the intent of a chunk of code regardless who the author is.
Perl at its worst can also be pretty arcane and I've heard it described as "executable line noise". That doesn't make for maintainability.
I moved to Python for a later project (a custom CI system) and while there were people of varying skill working on it, the code looked the same because of the "only one way to do it" philosophy. Similar formatting, same idioms, readable code etc. This alone justified moving to Python for me. I could fix a problem in about a tenth of the time I needed to fix a similar bug in the perl codebase.
A huge part of this is due to the bad coding practices and relative inexperience of the programmers on the perl project. However, my feeling is that, perl is forgiving when it comes to style. It allows a skilled used to create really beautiful programs but pays the price by allowing terrible programs by bad programmers to run sufficiently well. We compared it to English. Very flexible, very forgiving when it comes to grammar and syntax if your intention is just to convey meaning.
(as far as I know, Python doesn't give you an error message when your function gets up to 66 lines, or whatever, long)
But, in my experience, because of the limitations on how flexible the language is, a 3000 line python function which is edited by multiple people is usually more readable than a 3000 line perl one.
Maybe a better question is: what makes 3000 lines single-function code so prevalent in Perl?
There's something to say about Perl 5 making function arguments difficult. But I don't think it ends there, because other languages attract the same kind of code.
YMMV, as they say.
(As an aside, you can make it more horrible because you don't even need a "run" function - just stuff it into the *.py file and it'll get executed :) )
> Yes, sometimes Perl looks like line noise to the uninitiated, but to the seasoned Perl programmer, it looks like checksummed line noise with a mission in life.
edit: formatting
This attitude is not very good in corporate environments where all code produced must be uniform so that new people can come and go and the software keeps churning out money.
Contrast this to Python which is a much more enterprise-y language, which is the reason for its success.
you mean, like string interpolation? :)