|Developer Diary · You Heard It Here First · Monday 2 February 2004|
Python has recently begun to come into its own and gather afficionadoes to its cause. For many years it was a language that held a great deal of fascination for programmers but noone used it because it was not really practical. It was sort of an object of theory and wonder. Programming Python was kind of like cultivating a wierd Australian plant that would go extinct in the presence of rabbits. With greater stability and module support that has appeared in the last two or three years that has been changing.
The attraction of Python is that it has a sophisticated object-oriented capability and good meta-class support. As a scripted language it has lots of neat features like first-class functions that attract old lisp lovers. It also has a lot of string and file manipulation power like you would find in PERL. Compared to Java it is more compact and flexible which means you can generally write complex general-purpose programs faster in Python than any other language. For example, PERL is great as long as you are a sysadmin who thinks a 300-line program is large, but once you start talking 50,000-line simulators Python looks a lot better.
Of course, for many years all this was immaterial because Python was not practical. It didn't run on Windows for starters and had many game-over problems. For example, until recently its garbage collection didn't really work reliably. Imagine investing six months writing a 10,000 line application and then finding out at the end that bugs in the garbage collector rendered your program inoperable in any kind of real-use situation where large amounts of memory were consumed. That was the kind of thing that killed off Python use. Even nowadays Python programmers struggle with garbage collection.
It's kind of ironic actually because one of the main points of Python was to free programmers from explicit memory management in C++. Sounds great: no more memory management. The only problem was there really was no more memory management. So as soon as program used enough memory, it stopped working.
Now they seem to have the MM problem enough under control that Python actually works most of the time so they can move onto other problems like GUI. Right now Python is not ready for serious GUI-dependent applications unless you want to experience some serious pain and angst, but it is no longer hopeless. For example, there is wxWindows for Windows and the usual tinker toy GUI toolkits for Unix are getting better. As things stand you can kind of cobble together enough of GUI that as long as you are not doing anything too fancy you will be ok.
Where Python really shines is in domain-specific areas like bioinformatics and scientific or business simulation. As long as calculation and data movement (rather than presentation) is the focus Python can be the best solution. These are the areas where the language is growing and getting real use. Python's power and simplicity lets you build models fast and its flexibility lets you turn them around and morph them to need.
A cool example of Python use is the decision of Icelandic company CCP to use it in their industry-leading MMORPG EVE Online. By marrying Python with Maya they have created one of the most visually powerful games ever invented. They use a Python splinter cell called Stackless Pthon. The idea of stackless is to use continuations internally to do away with the C-stack. In EVE this allows them to use objects to model millions of entities with less of a resource burden on the servers because there are no threads. This approach is innovative and well-aimed. As I stated back in my December article Dread of Threads, threads are a poor paradigm on a lot of different levels. It's good to see developers creating better alternatives.
For their interface EVE developers obviously did not use the crude Python offerings. Instead they draw their own line by line using DirectX. This confines their application to Windows, but in return they get acceptable performance and a crafted look.
Python still has too many weaknesses to supplant Java but who says they are competitors . With Jython you can combine Python and Java. For example, if we ever wanted to add scripting to our ODC program at OPeNDAP.org we could include a Jython engine and users would be able to programmatically control the ODC and do calculations on data using Python's enormous power.
Python's promising future seems to be arriving at last.
|return to John Chamberlain's home · diary index|
|Developer Diary · about · email@example.com · bio · Revised 2 February 2004 · Pure Content|