The Key Thing In Python’s Favour
I recently ran across this post advocating Python. This made me think about why I prefer Python over the rest of the scripting crowd. And I realised that there is just one key reason:
Python is easier to read
That’s it. For all the joys of programming in dynamically-typed languages, I think there is one major problem: in many ways these languages favour writers over readers. I covered one example of this problem back in my post on Duck Typing vs Readability. This is why it is so important that a dynamic language is designed with readability in mind.
In my opinion, Python really shines readability-wise. And this is no accident — if you follow design discussions about Python you will see that Guido is always concerned with code clarity. A feature is not worth adding just because it makes code more compact; it must make the code more concise. Features have even been removed from Python because they were seen to encourage compact but difficult to comprehend code (reduce being a classic example). Even controversial design choices like significant whitespace and the explicit use of “self” are actually good for readability.
The philosophy behind Python also extends beyond the language design. Clever tricks and one-liners are not encouraged by the community. Rather, the community aims for Pythonic code:
To be Pythonic is to use the Python constructs and datastructures with clean, readable idioms.
This is surely refreshing compared to the misguided boasting about how much can be crammed in to a few lines of [insert other scripting language]. Certainly, if I ever have to pick up and maintain another person’s dynamically-typed code, I hope it is Python. And since I know I will have to maintain my own code, when I go dynamic I always pick Python.









September 6th, 2007 at 9:57 pm
You’re right – Python is very readable, nice and clean. But, in my opinion to a point were it gets a little boring – there are often only one way to do things. Perl on the other hand is totally flexible – but also completely unreadable. I think Ruby is a good compromise, it can be used to make clean readable code but there also a greater freedom for ‘creative’ programming.
September 6th, 2007 at 11:11 pm
About Perl…the “readability” thing gets a little old. If you can’t make your Perl code readable don’t blame Perl; blame yourself. You *can* write hard to read Python code. Ruby is not that much better than Perl if you want to throw the “readability” thing out there because the statement from Magnus about Ruby being a good compromise applies directly to Perl as well. The “total flexibility” of Perl is one of its many strengths.
September 7th, 2007 at 1:53 am
Culture matters more to a language than most people think. It’s true that one can make Perl code readable, but most Perl code I see isn’t. Why? Because culturally, Perl hackers love to take advantage of implicit variables, of clever one-liners, etc.
A Python program’s readability is supported by language design choices, idiom, and culture. A Perl program’s readability is only _in spite of_ these things. That’s the difference.
(That said, I love using Perl for certain tasks!)
September 7th, 2007 at 3:09 am
Reading code is about understanding intent, and good comments and a thought out system design in general are much more important towards that end. A consistent indentation structure is nice, but how much does it REALLY give you?