Among the languages favoured by Web developers and innovators, particularly those in the open-source community, three of the most popular are the alliterative Perl, PHP and Python.
Python is emerging as a powerful alternative to the more traditional choices – Perl and PHP.
Python is attractive because of its ease of use; its high level of abstraction from the hardware; its extensive support for housekeeping activities such as I/O, memory management, data typing and variable binding; and, perhaps most important, the fact that programmers can be highly productive with the language.
Python was created in the late 1980s by Dutch programmer Guido van Rossum and was named after the BBC television comedy series Monty Python’s Flying Circus.
- ease of use
- high level of abstraction from the hardware
- extensive support for housekeeping activities
- promotes highly productive programmers
You can consider Python either a scripting language (see box below) or a “regular” programming language. It offers an interactive mode for quick development and testing, as well as a noninteractive mode for ease of reuse.
In fact, Python doesn’t actually contain anything new — every feature has been taken from some other language. These practical capabilities are wrapped up in a simple package that’s available for anyone to download and use without restriction; not even the GNU Public License applies.
Like Java, Python has a small core and a large, extensible library of functions and procedures. Thus, most of what a programmer is likely to need already exists in written, tested form and can be used with simple library calls glued together with a small amount of new code.
One measure of Python’s programmer-friendliness is its reliance on a simple indentation hierarchy for grouping sections of code, which eliminates the need to match Begin/End statements or to count parentheses, brackets or curly braces.
Even so, Python is a general-purpose programming language that offers far more structure and support for large programs than simple shell scripts and much more error checking than lower-level languages such as C.
Python is object-oriented with built-in, high-level data types, including flexible arrays and dictionaries. It can be applied to much larger problems than languages such as Awk or even Perl can, yet it remains as easy to use as those languages.
In a 2000 interview with Linux Journal (www.linuxjournal.com/article/3882), programmer, author and open-source advocate Eric S. Raymond recounted his initial experience with Python:
“A couple of hours into the project, I noticed (allowing for pauses needed to look up new features in Programming Python) I was generating working code nearly as fast as I could type. . . . This was my first clue that, in Python, I was actually dealing with an exceptionally good design. Most languages have so much friction and awkwardness built into their design that you learn most of their feature set long before your misstep rate drops anywhere near zero. Python was the first general-purpose language I’d ever used that reversed this process.”
The power of Python can also be suggested by some of its users. According to Peter Norvig, director of search quality at Google Inc. in Mountain View, Calif., “Python has been an important part of Google since the beginning and remains so as the system grows and evolves.”
You’ve also seen Python in action at your local cinema. “Python plays a key role in our production pipeline,” says Tommy Burnette, a senior technical director at special-effects studio Industrial Light & Magic (ILM) in San Rafael, Calif. “Without Python, a project the size of Star Wars Episode II would have been very difficult to pull off. From crowd rendering to batch processing to compositing, Python binds all things together.”Without Python, a project the size of Star Wars Episode II would have been very difficult to pull off.Tommy Burnette>Text Burnette’s sentiments are echoed by Philip Peterson, ILM’s principal engineer for research and development. “Python is everywhere at ILM,” he says. “It’s used to extend the capabilities of our applications, as well as providing the glue between them. Every [computer-generated] image we create has involved Python somewhere in the process.”
Follow the script
While all these languages are capable of creating many types of applications and systems from scratch, scripting languages are especially good at communicating with program components that have been written in other languages. Programs (also called scripts) are usually stored only as plain ASCII text and interpreted at runtime, though some languages, including Perl, compile a script each time they’re invoked.
In addition, scripting languages are often designed for interactive use and feature many commands that can be executed individually. In some scripting languages, such as sh, the classic Unix shell, most operations are actually programs in their own right. The use of such high-level commands considerably simplifies the process of writing code.
In the early days of computers, when machines had limited storage and memory, programs had to be supercompact and ultraefficient. Small and quick meant everything, while simplicity and elegance (or even the understandability of code) didn’t count. As hardware has become vastly more powerful and software needs have become far more complex, however, users have had to expend much more effort on refining the development process — especially prototyping and rapid development models — at the expense of pure code efficiency.
In today’s environment, scripting languages make good sense. Developers can take for granted important programming features such as automatic memory management and bounds checking. When using a nonscripting language on the other hand, programmers have to expend time and effort — and write much more code — to manage memory and variables and to create needed data structures. Besides allowing faster and more-productive programming, script files are usually much smaller than equivalent program files written in C.
Today, many enterprise-class development projects use both a scripting language and a lower-level programming language in tandem. Each language helps to solve specific problems for which it’s better suited.
— Kay is a Computerworld contributing writer in Worcester, Mass. You can reach him at [email protected].