One of my favorite characters on TV, Leroy Jethro Gibbs, has a list of rules that he is always quoting to his subordinates. It is an endearing quality that he uses to convince them that he has everything figured out so well that he has it codified into a set of rules.
Alan J. Perlis, winner of the first ACM Turing Award, also has a list of rules, or rather epigrams. He listed a number of them in an article that he published entitled Epigrams on Programming. This is a set of rules for programmers to live by. One of my favorites is:
A language that doesn’t affect the way you think about programming, is not worth knowing. – Alan J. Perlis
I have been finding this particularly true of Python. It is often said that it is not at all hard to write bad code in any language. The converse however is rarely true. Python is the exception though. It is genuinely easy to write good, understandable code in Python.
… programs must be written for people to read, and only incidentally for machines to execute. – Harold Abelson and Gerald Sussman in the preface to their book Structure and Interpretation of Computer Programs
And why is this so? Machines don’t have any problem dealing with complexity. In fact, machines don’t have to understand programs. They just blindly execute them. That is one of the first things that you learn when you start to program.
The reason that you program in a higher level language is so that you can wrap your brain around what your program actually does. And Python helps you do that in several ways. First, by using indentation to indicate the boundaries of a block, it makes scope visually obvious. It also saves lots of time spent arguing about programming style by having the style dictated by the syntax of the language.
Another helpful feature of Python is the distinction drawn between None
and False
and 0
. The first indicates the lack of a value, the second is a boolean value, and the last a numeric value. It is not until you need to make the distinction between these roles in a program that you appreciate a language that doesn’t conflate them. It is easy enough to convert between them when that is what you intend.
The last feature that I will describe is the fact that variables are containers for values. These containers don’t intrinsically have data types. The values they contain have types and those types can be discovered by introspection but just as a variable can store different values at different times, those values are not constrained to always be of the same type.
These three attributes serve merely as examples, not an exhaustive list. The more I use Python, the more I appreciate what a long list of features it is. It meets the criteria set by Seymour Papert for the Logo language:
A language should have a low threshold and no ceiling.
That is to say, you should be able to do interesting things with a small vocabulary of four or five words, and yet do anything you can imagine with the full language.
Sweet dreams, don’t forget to tell the ones you love that you love them, and most important of all, be kind.