Unformatted text preview:

1 Reasons to Use Python1.1 Programmability1.2 Prototyping1.3 Simplicity and Ease of Understanding1.4 Java Integration2 Arguments and Rebuttals3 Useful ResourcesPython Advocacy HOWTORelease 0.03A.M. KuchlingApril 20, [email protected]’s usually difficult to get your management to accept open source software, and Python is no exception to this rule.This document discusses reasons to use Python, strategies for winning acceptance, facts and arguments you can use,and cases where you shouldn’t try to use Python.This document is available from the Python HOWTO page at http://www.python.org/doc/howto.Contents1 Reasons to Use Python 11.1 Programmability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11.2 Prototyping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Simplicity and Ease of Understanding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.4 Java Integration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Arguments and Rebuttals 43 Useful Resources 51 Reasons to Use PythonThere are several reasons to incorporate a scripting language into your development process, and this section willdiscuss them, and why Python has some properties that make it a particularly good choice.1.1 ProgrammabilityPrograms are often organized in a modular fashion. Lower-level operations are grouped together, and called by higher-level functions, which may in turn be used as basic operations by still further upper levels.For example, the lowest level might define a very low-level set of functions for accessing a hash table. The next levelmight use hash tables to store the headers of a mail message, mapping a header name like ‘Date’ to a value such as‘Tue, 13 May 1997 20:00:54 -0400’. A yet higher level may operate on message objects, without knowingor caring that message headers are stored in a hash table, and so forth.Often, the lowest levels do very simple things; they implement a data structure such as a binary tree or hash table, orthey perform some simple computation, such as converting a date string to a number. The higher levels then containlogic connecting these primitive operations. Using the approach, the primitives can be seen as basic building blockswhich are then glued together to produce the complete product.Why is this design approach relevant to Python? Because Python is well suited to functioning as such a glue language.A common approach is to write a Python module that implements the lower level operations; for the sake of speed,the implementation might be in C, Java, or even Fortran. Once the primitives are available to Python programs, thelogic underlying higher level operations is written in the form of Python code. The high-level logic is then moreunderstandable, and easier to modify.John Ousterhout wrote a paper that explains this idea at greater length, entitled “Scripting: Higher Level Programmingfor the 21st Century”. I recommend that you read this paper; see the references for the URL. Ousterhout is theinventor of the Tcl language, and therefore argues that Tcl should be used for this purpose; he only briefly refersto other languages such as Python, Perl, and Lisp/Scheme, but in reality, Ousterhout’s argument applies to scriptinglanguages in general, since you could equally write extensions for any of the languages mentioned above.1.2 PrototypingIn The Mythical Man-Month, Fredrick Brooks suggests the following rule when planning software projects: “Plan tothrow one away; you will anyway.” Brooks is saying that the first attempt at a software design often turns out to bewrong; unless the problem is very simple or you’re an extremely good designer, you’ll find that new requirementsand features become apparent once development has actually started. If these new requirements can’t be cleanlyincorporated into the program’s structure, you’re presented with two unpleasant choices: hammer the new featuresinto the program somehow, or scrap everything and write a new version of the program, taking the new features intoaccount from the beginning.Python provides you with a good environment for quickly developing an initial prototype. That lets you get theoverall program structure and logic right, and you can fine-tune small details in the fast development cycle that Pythonprovides. Once you’re satisfied with the GUI interface or program output, you can translate the Python code into C++,Fortran, Java, or some other compiled language.Prototyping means you have to be careful not to use too many Python features that are hard to implement in your otherlanguage. Using eval(), or regular expressions, or the pickle module, means that you’re going to need C or Javalibraries for formula evaluation, regular expressions, and serialization, for example. But it’s not hard to avoid suchtricky code, and in the end the translation usually isn’t very difficult. The resulting code can be rapidly debugged,because any serious logical errors will have been removed from the prototype, leaving only more minor slip-ups in thetranslation to track down.This strategy builds on the earlier discussion of programmability. Using Python as glue to connect lower-level compo-nents has obvious relevance for constructing prototype systems. In this way Python can help you with development,even if end users never come in contact with Python code at all. If the performance of the Python version is adequateand corporate politics allow it, you may not need to do a translation into C or Java, but it can still be faster to developa prototype and then translate it, instead of attempting to produce the final version immediately.One example of this development strategy is Microsoft Merchant Server. Version 1.0 was written in pure Python,by a company that subsequently was purchased by Microsoft. Version 2.0 began to translate the code into C++,shipping with some C++code and some Python code. Version 3.0 didn’t contain any Python at all; all the code hadbeen translated into C++. Even though the product doesn’t contain a Python interpreter, the Python language has stillserved a useful purpose by speeding up development.This is a very common use for Python. Past conference papers have also described this approach for developinghigh-level numerical algorithms; see David M. Beazley and Peter S. Lomdahl’s paper “Feeding a


View Full Document

GT AE 6382 - Python Advocacy H

Download Python Advocacy H
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Python Advocacy H and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Python Advocacy H 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?