It is hard to write unreadable code in python.... You can still have meaningless variable names, bad encapsulation, functions that are too long, tight coupling, and poor/no documentation, and no tests. However if you compare a program written in python to a program written in some other language, the python program will not be less readable unless effort was put into making the python program less readable.
— Python's Magic Powers of Readability in the Face of Barely-Competent Monkeys
I think I'll credit this one as "I hate dollar signs and luuuuuurve prefix and postfix underscores, nanny-nanny-boo-boo."
Of course my favorite line is "You should learn some other programming languages." I counted how many languages I've programmed in to get Perl 6 out the door the other day... and stopped at ten.
Re:It's about program design, stupid!
chromatic on 2007-09-10T17:49:42
Design is a readability problem no matter which language it is.That's why I prefer to talk about "maintainability" rather than "readability". It shifts the discussion away from syntax to other factors which actually matter.
Re:Second order effects of language syntax
chromatic on 2007-09-10T22:21:35
Great thoughts, as usual Ziggy.
Therefore, any Python programmer of even the most basic skill level should be able to read any Python program (if not completely understand the underlying algorithm and data structures).Without being able to understand the program's design in the large or small, is being able to read the program even interesting? I can't think of a case where it is. Am I missing something?
Re:Second order effects of language syntax
ziggy on 2007-09-11T18:27:14
I think you're approaching the problem from the wrong direction.Without being able to understand the program's design in the large or small, is being able to read the program even interesting?
Given a new program and no previous understanding of how it works, you could read the program and build an understanding from there. Consider the first time you approached a full set of basic binary tree primitives, or a bubble sort. It may have been the first time you came across these concepts, but if you could read the code, you could understand what was going on without too much difficulty.
Now, consider the first time you came across code for a balanced binary tree, an AVL tree, or quicksort. There probably wasn't enough information there for you to understand the algorithm completely, either in terms of how it worked or how it behaved (i.e. time/space performance).
For a more pragmatic example, consider any of the programs from Matt's Script Archive. You may not understand what it is trying to do, but you can read it. If you've got more than a passing background in Perl, you'll probably find at least a dozen howlers before you understand the program. For a more mundane example, consider a program that passes everything through a magic regex. If you can read the regex, you can determine that it is a buggy RFC 822 matcher, and should probably be replaced, because no simple regex can email addresses. If you can't read the regex, then this is just a piece of cargo-cult code with magical properties.
Reading a program without prior understanding is interesting because it is a gateway to gain that understanding. It's a necessary precondition, but not a sufficient one.Guido's right that readability is an important property, because if you can't read a block of code, you have no hope of understanding it. Consider quicksort written in APL or befunge. You may understand quicksort, but you wouldn't be able to find and fix a bug. Even Tony Hoare himself would have trouble.I can't think of a case where it is. Am I missing something?
I won't speak for Guido, but a plethora of anonymous and interchangeable Pythonistas cite "readability" as if it were identical to "understandability". If this were the case, then Python indeed would have magic pixie dust, Chandler wouldn't be years behind schedule, and frameworks like Zope and Twisted wouldn't be so horrifically unapproachable.Re:Second order effects of language syntax
Aristotle on 2007-09-11T00:31:05
The unintentional side effect is that a moderately experienced Python programmer needs to read, rather than skim, each and every Python program he picks up to determine if it’s total crap, moderately good, well-written and crystal clear, clever for good reasons, or written while drunk.
That’s how I feel about Java. Regardless of how crappy the code, it always looks reasonable on a microscopic level.