The Artima Developer Community
Sponsored Link

Python and the Tipping Point
A Conversation with Bruce Eckel, Part IV
by Bill Venners
July 21, 2003

<<  Page 3 of 5  >>


Python Lets Me Focus on Concepts

Bill Venners: Your number one reason for loving Python, according to your keynote, was "Python lets me focus on concepts."

Bruce Eckel: With Python, the code gets out of my way, so I can get to the problem am I actually trying to solve, very soon. With other languages I've used, it's very easy to get bogged down in thinking, "What do I need to do first. OK, open this file and read all its lines. How do I do that?"

Bill Venners: So the tool you are using to build something, Python, stays out of your way such that you can just focus on the thing you're building.

Bruce Eckel: Yes, and you can very quickly put these structures together. For example, if you have an object-oriented design, you can quite quickly mock it up in Python. You could type the Python code in almost as easily as a pseudo-code representation, but you would have something that would execute so you could test the validity of your structures. That's why they often call Python "executable pseudo-code." To test your design, you could go ahead and create your classes in Python and make sure they fit together. And then if you want to write the program in some other language you could.

Bill Venners: It's very hard to think of everything up front before you start coding. When you do a design, you think of some things, perhaps most things. But when you go to implement it, you may learn all kinds of things that change the design. Getting to a good design usually requires an iterative process. The design improves over time and eventually achieves some kind of stasis that you release. It seems like the quicker you can get through that process, the better.

Bruce Eckel: Yes. You get your program as close to possible to what you think it should be, and then all the realities appear. The sooner you can do that, the sooner you can start fixing those things.

Bill Venners: In Programming Python, author Mark Lutz writes:

Python makes it incredibly easy to throw together a bad design quickly. It's a genuine problem. Because developing programs in Python is so simple and fast compared to traditional languages, it's easy to get wrapped up in the act of programming itself, and pay less attention to the problem you are really trying to solve.
In other words, because Python let's you create working programs so quickly, psychologically it tends to seduce you away from planning or designing. You don't aim with design. You just shoot with code. And you may end up with code that is not very well thought out. Have you ever experienced that?

Bruce Eckel: I've heard that approach referred to as: "Ready, fire, aim." You shoot first and see where the bullets go. Then you know where to aim. I think Python allows me to try something out, and then I can refactor it as I understand the design better. You might say Python produces more emergent designs, and therefore sometimes better ones.

On the other hand, there are a fair number of programs I have written that I have just gotten working enough to solve my problem and then stopped, even though it wasn't the most elegant way that I could do it. And I think those are OK too. If I ever need modify those again, then I will at that time be encouraged to refactor the design. At that time I'll know the sorts of things am I changing, so I can focus my refactoring on how I can make those changes easier.

Bill Venners: You can always refactor later if you need to.

Bruce Eckel: Exactly. You can refactor on demand. If I'm using and changing a program a lot, and I really want to be able to understand it better so I can continue to change it, then I'm more compelled to say it really needs to be a good design. If you think about it, should you spend that kind of effort on every program that you implement? Because some of them are just one shot deals that solve a problem. You don't really need to change it once you get it working. Of course ideally while you're writing it you're going to apply your normal practices to it, but why should you spend extra time working out this super good design if it's just a one shot program.

<<  Page 3 of 5  >>

Sponsored Links

Copyright © 1996-2018 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use