1.2.1 What is Python?

The ``What is Python?'' page on http://www.python.org describes Python as:

``an interpreted, interactive, object-oriented programming language. It is often compared to Tcl, Perl, Scheme or Java.'' [their emphasis]

By interpreted it is meant each time a program is run the interpreter checks through the code for errors and the interprets the instructions into machine-readable ``bytecode''. Perl is perhaps the best known example of an interpreted language.

This is different to a compiled language (such as C) which is compiled only once and produces a binary executable which can then be run again and again, even on different physical systems of the same architecture1.2. This means programs written in Python generally run more slowly than programs written in C. Run-time speed reductions ranging from factors of two to an order of magnitude or more are typical. However, the compile-debug cycle and prototyping of algorithms is much quicker an interpreted language such as Python. In general programs may be written in less time in Python but will take longer to run.

Python is interactive. In one mode of operation Python is used in much the same way as the Unix command line; a Python statement is entered, followed by the Return key and, if appropriate, the result is printed on the screen. This is particularly advantageous in the debugging process, and is the natural way of working in many mathematical programming and visualisation environments used in the physical sciences such as Mathematica, Matlab and IDL.

Python is object-oriented by design. Object orientation provides a powerful way of abstracting the data structures and flow of programs. It is not yet used as much in the physical sciences (and may never be), which is partly due to the naturally procedural way of thinking about algorithms, and partly to a culturally entrenched way of programming, originating in the days before OOP.

C and Fortran are perhaps the most popular procedural languages in academia. C++, Perl and Java are the most widely used OO languages. However, it is worth noting that, of these, only Java was explicitly designed as an OO language. The OO components of both C++ and Perl take the form of extensions to a underlying procedural structure. Sometimes this leads to a confusing implementation, particularly in C++, which is often dismissed as too baroque for non-experts.

Python is portable. The Python interpreter can be installed on any architecture for which there exists a C compiler. In particular it can run on the Sparc-based SunRay system in the laboratory, and on Intel-based PCs running both Microsoft Windows and Linux. Furthermore, because it is interpreted, programs written on one architecture will generally run on another1.3. This allows students to write programs on their own PCs1.4 and bring them into the department to show to a demonstrator. The interpreter is available pre-compiled, protecting students from the difficulties of building a large application from source code. The Windows binaries are particularly simple to install; they come in the form of a GUI installer and their installation consists of little more than clicking ``Next'' a few times.

Furthermore, Python is Free. Releases on all platforms are available free of charge (although as with many open source projects, it is possible to pay for a customised commercial distribution) and the source code is open-source.

In an attempt to measure the popularity of various programming languages, I entered their names into the Google search engine, and tabulated the number of results (see Table 1.1). Obviously, this is not a very scientific measurement, but does offer some indication of Python's relative popularity.


Table: Searches for language name AND either ``code'' OR ``language'' OR ``program'' in order to get meaningful results from searches for ``C'' and ``Python'', both of which have other meanings. http://www.google.com accessed 3/6/2002.

Language Search results returned
C 4,930,000
Java 2,670,000
C++ 1,800,000
Perl 1,690,000
Python 838,000
Pascal 652,000
LISP/Scheme 629,000
Fortran 602,000




Footnotes

... architecture1.2
However, each time the program is changed it must be recompiled.
... another1.3
Unless they use the OS-specific libraries such as those which change file permissions and access system variables.
... PCs1.4
Ownership of computers amongst undergraduates is increasingly common.