A high-level language worthy of your tool kit
|
|
|||
|
|
python 1. any of a genus of large, nonpoisonous snakes of Asia, Africa and Australia that crush their prey to death. . . . 3. totally awesome, bitchin' language that will someday crush the $'s out of certain other so-called VHLL's ;-)
-Guido van Rossum from the Python Web site (www.python.org/doc/ Summary.html)
This week, Gearhead looks at a way-cool programming language called Python. "Not another language!" Gearhead hears you cry. "Why should we care about Python?"
The answer is Python is easy to learn, efficient, stable, elegant and available on a significant number of platforms. It also offers a substantial reduction in development time compared to C, C++ or even Java. And finally, the cachet of being able to program in Python may be useful at parties ("Hey, ever heard of Python?" . . . well, maybe not).
The language is the creation of a Dutchman, one Guido van Rossum, and the language's name is somehow related to the fact that Guido's favorite comedy show at the time Python was developed (around 1990) was Monty Python's Flying Circus.
Python is a very high-level language (VHLL) that supports object-oriented programming. It is similar to Perl and Tcl (which we will cover in a future "Gearhead" column) and has gained a loyal following. Better yet, its open source development has been aggressively continued - on April 13, van Rossum released Python Version 1.5.2.
As noted, Python is portable and has been implemented on Amiga, BeOS, QNX, VMS, Windows CE, Psion, Linux, Sun Solaris, SGI IRIX, DEC Unix, IBM AIX, HP-UX, SCO, NeXT, BSD, FreeBSD, NetBSD and Windows. And better still, the source code to the language is freely available under the GNU license, which means that you can modify it as you see fit.
The language has some important features, least of which is the indenting of source statements that makes source code easier to read (Gearhead has often opined that source code that looks good tends, more often than not, to be good). Python can be extended with C, uses automatic memory management, interfaces with operating system libraries, performs system calls and executes quickly (although, as always, if you want raw speed, scripted languages aren't the way to go).
Python can be used as a scripting language for browsers (with a plug-in) and Web server applications, including Microsoft's Active Server Page (ASP) technology (see "Gearhead," NW, April 12, page 36). And as proof, it can be used for real-world applications: The scoreboard system for the Melbourne (Australia) Cricket Ground and Zope, a terrific Web application server, are both written in Python.
All Python programs are called modules. Modules can be imported (Pythonese for "used") by other modules and can be reloaded dynamically so changes in source code can be made and effected during execution.
Python comes with a slew of modules that provide systems services, graphics and math functions, as well as file and network input/output support. Also included are open source programs that implement Web servers, editors, databases and other useful functions.
Strictly speaking, Python is a compiled language in the same manner that, say, Java is compiled: On execution, the Python source code is parsed and a "byte code" version is produced. The byte code is a platform-independent program that is, in turn, interpreted by the Python run-time system.
While Python and Java share some attributes, Java is far more rigorous in its security model and far richer in terms of interface and function libraries. On the other hand, a Python program will usually execute faster than a Java program and the language is easier to learn.
Python is an incredibly useful gizmo to have in your tool box, and the price is right. Python gets a Gearhead rating of a full five gear teeth out of five.
Code to gh@gibbs.com.
>

