An Interview with Mark Lutz: Author of Programming Python, 2nd Editionby Bruce Stewart
Stewart: A lot has happened in the Python world since you first wrote Programming Python in 1996. What are some of the most significant changes?
Lutz: Technically speaking, the language has sprouted lots of nice new features, including module package imports, class exceptions, pseudo-private class attributes, Unicode, and much more. But perhaps the most important change is Python's growth in popularity. In the last few years, it seems to have reached a critical mass in terms of acceptance that was difficult to imagine in 1996.
In 1996, Python was still something of a tool that appealed mostly to pioneers -- people who were willing to grab a fairly new language off the Net and learn it by experimenting. Today, Python is used by something like half a million people in companies around the world. For instance, it is being used by Disney, Origin, and Industrial Light + Magic to script animation; by Intel to test chips and boards; by Yahoo! to implement Web content; by NASA and Lawrence Livermore Labs to do numerical programming; by Red Hat to install Linux; and by far too many other companies to list here. It's become a very common and widespread development tool.
In fact, most of the people in the classes I teach these days are there because they've been told that they have to use Python at their job, not because they'd like to experiment with something new. That's a fairly radical user-base shift and it speaks volumes about how far Python has come. Python is a nice thing to be forced to use, of course, but the language is clearly in a very different place in terms of visibility. To me, this new level of acceptance is a much more compelling change than any specific language feature.
Don't miss O'Reilly's Open Source Software Convention, in San Diego, California. You'll find sessions and tutorials on Apache, MySQL, Perl, PHP, PostgreSQL, Tcl/Tk, General Open Source, as well as Python.
Stewart: Python has the reputation of being elegant and friendly to use. It has been said that Python looks like it was designed, not accumulated. Which features of the language make it a pleasure to use for programmers?
Lutz: Yes, there is indeed a sort of instant gratification to Python programming that makes development just plain fun. It's something that needs to be experienced, of course, but there are tangible things that make Python very developer-friendly. Among them: a lack of compile and link steps (you type code and it runs immediately), the absence of type and size declarations (names are dynamically bound to objects), powerful built-in object types and tools, and a very clean and coherent syntax and design.
The last of those may be Python's best gift to programmers. The clutter that interferes with programming in other languages just isn't there in Python. Guido is a mathematician at heart, and it shows in the elegant language design he crafted. As underscored by a slogan from the most recent Python conference, Python just seems to fit your brain.
Just as important, Python's clean syntax also makes code readable, which in turn makes it maintainable. In the real world, being able to change code is usually just as important as getting it to work in the first place. A good programmer knows that he or she must write code for both the computer and for human readers, and Python makes this a snap.
In broader terms, Python is optimized for things like software quality, portability, integration, and productivity. It fosters maintainable systems that run just about everywhere and can be freely mixed with other software components. But productivity is really the name of the game in Python: It's focused on speed of development, not speed of execution. That is, it's about making life easier for developers, not computers. Because of that, Python programs are typically a fraction of the size and complexity of their equivalents in C++ or Java, so they can be written and debugged much quicker.
These days, one of the things I hear most often on the training road is that it's tough to find developers with time to implement software. As a language optimized for developer productivity, Python seems a direct answer to the software development crunch--you can do more in less time, without sacrificing code quality. Beware, though; once you've started using Python, you may find yourself loathing as I do the idea of ever going back to a language like C or C++.
Stewart: Let's talk about whitespace. Probably the most common feature that jumps out at programmers looking at Python for the first time is the way it deals with whitespace, where indentations are part of the language's syntax. Eric Raymond (a Python advocate) went as far as to say, "It's hard to blame anyone, on seeing this Python feature, for initially reacting as though they had unexpectedly stepped in a steaming pile of dinosaur dung." What are your thoughts on this unique syntax, and do you ever miss curly braces?
Lutz: Whitespace only really matters in Python all the way to the left of code, where it is used to group a given nested block. But no, I never miss the braces. In fact, I forget to type them in my C++ code all the time, which triggers all sorts of interesting noise from the silly C++ compiler. Really, the braces are only there in C/C++ for the compiler's benefit, not for yours.
What Eric's characteristically colorful comment doesn't hit on is that most people who have actually used Python consider the indentation syntax for blocks to be an important, if not downright critical, feature of the language. It forces you to write readable code, which in turn fosters code maintainability. It's a big win, once you get past the initial shock.
It turns out that in any structured programming language, the indentation of blocks really does mean something, and using it consistently matters. Trust me on this. A few years ago, I typically got paid to work on very large, very old C++ programs that had been maintained by many programmers. Because each of the programmers who touched the code had a very different indentation style, a block wound up all over the place--it would be indented two spaces in one place, then six in another, then one, and so on. The result was code that was utterly incomprehensible due to its inconsistent indentation.
Most Python users think that enforcing some consistency in indentation is not only good software engineering, it's simple common sense. The end result is code that is so well laid out that it resembles something akin to poetry. Much of the syntactic noise of a language like C is nowhere to be found.
This scheme may indeed be a new idea to people with backgrounds in C, but this industry hardly has a track record of resisting new ideas. And really, things like this tend to get an inordinate amount of attention on the Net. Once you start writing real Python programs, you'll probably find that the braces-versus-whitespace issue is much less important than things like directory walkers, socket calls, and GUI APIs. For real applications, people around the world have found that Python has exactly what it takes to get the job done.
Stewart: There seems to be a lively (or tired, depending on your perspective) ongoing discussion of the relative merits of Python vs. Perl. What are the most significant differences between the two languages?
Lutz: To be honest, I don't really fight this battle much anymore. It seems to me that most people who honestly compare the two languages will come to the right conclusion (and pick Python). Seriously, both languages have their own merits: Perl is still great at grokking text for patterns, and Python seems to excel as a general-purpose language. Naturally, I think Python's readability makes it better when it comes time to read and change someone else's code (or your own, a few months after you've written it). But this all seems so obvious to everyone I talk to these days that I don't feel the need to bang the drum about it anymore. There are more productive ways that Pythonistas can spend their time.
To keep on top of the latest developments in Python, visit the O'Reilly Network's Python DevCenter.
Stewart: As you mentioned, Python has made its way into some pretty high-profile projects like Industrial Light + Magic using it on the latest Star Wars movie, Disney using it for animation, and RedHat using it for Linux installers. In what areas is Python becoming more popular, and where can we expect to see it pop up in the future?
Lutz: It's tough to predict the future, but I think that Python's XML support will become very important in the near term. As a clean, object-oriented language, Python is a natural fit for XML-based data representation. The emerging C#/.NET port of Python from ActiveState might turn out to be important too, depending on how much stock you place in C# in general. The Zope Web framework is giving Python a big boost in the Web development world as well.
I mentioned some of the big-name companies using Python earlier. But the one obvious thread among them is that there is no obvious thread: Python shows up all over the map in terms of application domains. As new technologies have emerged over the years, the Python community has been quick to embrace and adopt them. The Jython (formerly JPython) system is a prime example: Instead of competing with Java, Jython enhances it by providing an incredibly seamless way to integrate Python scripts into Java applications. The C#/.NET port does something similar for that emerging technology.
I've seen potential Python "killer applications" come and go over the last decade, and new ones appear all the time. To me, though, Python's big strength is that it applies just about everywhere. It's not just for Internet scripting, GUIs, systems programming, text processing, or integration; it's for all of them and more.
Stewart: Python seems like a good choice as an instructional programming language due to its relative clarity and simplicity. Has it made any inroads as a teaching language?
Lutz: Yes. There is a very active education SIG (special interest group) in the Python world, working hard at positioning Python as a teaching language, and I know of schools that are indeed starting to teach programming with Python. Some of this movement's initial motivation came from Guido's CP4E project--Computer Programming for Everyone. That project is apparently defunct now, but the ideas it generated are as strong as ever.
On a non-empirical note, if my 14-year-old son is any indication, Python's simplicity and structure will also make it ideal among kids just starting to program. Well, that, and things like the PyGame game programming package do wonders to address the interests of this demographic.
Teaching Python--O'Reilly editor in chief Frank Willison talked last year with high school computer-programming teacher Jeff Elkner, who is delivering on the promise of Python as a first teaching language.
Stewart: Guido van Rossum, the creator of Python, is sometimes called its BDFL (Benevolent Dictator for Life). Do you have any concerns about this type of arrangement, where one person essentially maintains control of the language?
Lutz: Not at all. It's been one of the main reasons that Python has worked out so well thus far. Ultimately, decisions need to be made about language evolution, and some of those decisions will surely rub some people the wrong way. I think it works much better, though, to have one rational person like Guido being the final arbiter, rather than a committee. Down the latter path lies C++.
Like most people, I don't always agree with the BDFL (especially when he wants to change things I've just written about in very large books), but he's generally right; and when he's not, he takes consensus into consideration.
I hope that someday a standard Python language definition emerges, if only to give Python users a baseline that they can be sure will not change arbitrarily in future releases. I have heard grumblings out there that the language may be changing too fast, especially after the 2.0 release. But the current BDFL-plus-general-consensus model has worked well for the last decade. I hope it stands for another.
Stewart: What do you think are the most exciting developments going on in Python right now?
Lutz: There is too much to mention here, really. But among the things I find most exciting lately are "Pippy," the Python port to the Palm OS (you can actually run a Python-coded Web server on your Palm!); the PyDoc and PyUnit systems; the emerging Python support for XML-RPC and SOAP; ActiveState's Komodo IDE and VisualPython products; the PyGame system; Python's growth in countries like Korea (which drew 1,000 attendees at a recent Python Conference); and so on. I'm also excited to see so many new Python books on the horizon. I think we'll be up to about 20 English books by the end of the year.
Stewart: What is Python 3000? Will we really have to wait that long?
Lutz: I hope so (just kidding). Really, Python 3000 is the tongue-in-cheek name given to a mythical, future Python release that might be arbitrarily non-backward-compatible with the current language. In reality, it probably won't be quite that different from Python today, and its features will be gradually phased-in over time, not released all at once.
As I mentioned earlier, there is some concern in the trenches about the language changing too much, too quickly. But Guido and his PythonLabs cohorts are very much aware of such concerns, and I doubt the community would tolerate too much code breakage in any event. You can't rip the rug out from under half a million people all that easily.
Stewart: What features would you like to see in future versions of Python?
Lutz: Nothing new really; I'm fairly conservative about adding things to the language. It seems close to ideal as is, and working on things like that tends to break them. Python is still very easy to learn these days, and I'd also hate to see that change.
I do like statically nested scopes, which will be added as a standard feature in 2.2. They'll eliminate a fairly tricky part of the language. But there is a fine line between fixing things and feature bloat. If everyone got their favorite little feature added to Python, it might wind up looking like another scripting language that starts with "P". Not that there's anything wrong with that . . . .
Mark Lutz is a Python trainer, writer, and software developer, and one of the primary figures in the Python community. He is the author of Programming Python and Python Pocket Reference, and coauthor of Learning Python. Mark has been involved with Python since 1992 and began teaching Python classes in 1997. In addition, he holds B.S. and M.S. degrees in computer science from the University of Wisconsin, and has worked on compilers, programming tools, scripting applications, and assorted client/server systems. Mark can be reached by email at email@example.com, or on the Web at http://rmi.net/~lutz.
O'Reilly & Associates recently released Programming Python, 2nd Edition (March, 2001).
Sample Chapter, Advanced Internet Topics, is available free online.
For more information, or to order the book, click here.