> Page Moved to www.itmaybeahack.com

This page has been moved to http://www.itmaybeahack.com/homepage/books/nonprog/html/p01_getting_started/p01_c05_cool.html. Please update your bookmarks.

Why Python is So Cool

We’ll ramble on a bit about Python and the reasons why it is so cool. This won’t really help you learn the language. It’s mostly op-ed material to provide some justification for why someone would invest time in learning Python. In Core Coolness we’ll cover some fundamental reasons why Python is cool. The FAQ in Coolness FAQ’s touches on a few more questions that sometimes get asked.

Core Coolness

Python reflects a number of growing trends in how people develop new computer programs. It is a very simple language, supported by an interpreter and surrounded by a vast library of add-on modules. It is an open source project, supported by dozens of individuals; this encourages you to build complete solutions from smaller components and partial solutions. We’ll look at each of these facets separately.

Planet Python. Python is really four separate elements in a single, tidy package. I like to think of it as an wonderfully efficient planet that we can visit. To get things done on that planet you have to learn the language. Once you’ve learned the language, however, you find that the whole planet is organized to do everything you ask precisely and very quickly. Like any well-run organization, it has a number of services that make life convenient and safe, and assure the common good of all the inhabitants. Finally, it offers a kind of public forum for making your requests and seeing the results of those requests.

This mythical Planet Python is the Python program itself, we’ll call it python in this book. Windows users may see it as python.exe. The Python program, python, runs on your computer, and carries out statements written in the Python language. The program has just one purpose – execute Python language statements – so it is small and efficient. Because it is so tightly focused, it is wonderfully reliable.

The planet’s services are the Python libraries. These libraries include programs you can extend, and pieces of programs that you might use to create a more complete program. Some parts of the libraries are both: things you extend to add new features, and then use in your final program. I think of these as essential services like police departments, public libraries, laundromats, and telephone sanitizers. You build your complete organization or enterprise using these pre-built organization units.

The public forum is the integrated development environment (IDE). This is the environment where you develop your Python program. It’s integrated because all the tools you might want are right there in a single program. In this case, the program’s name is IDLE. You use IDLE to write Python statements, execute sequences of Python statements and read any resulting messages.

Simplicity. Python is a relatively simple programming language that allows you to express data processing in clear, precise terms. The Python language has an easy-to-use syntax, focused on the programmer who must type, read and understand a program. The language is designed to look a bit like a natural language, with simple punctuation and indentation. Computer languages are more rigid than human languages: when you misspell something in English, people can often determine what you meant, and make sense of what you wrote. The Python program, python , is only a simple piece of software: spelling and punctuation really matter. While Python is easier than most other programming languages, you must still be precise.

Interpreted. The computer science folks characterize the Python program, python , as an interpreter : it interprets and executes the Python language statements, doing your data processing. Because it is interpreting our statements, it can provide useful diagnostic information when something goes wrong. It can also handle all of the tedious housekeeping that is part of how programs make use of the computer’s resources. As users, we don’t see this housekeeping going on, and as newbie programmers we shouldn’t have to cope with it, either.

The computer-science types make a distinction between interpreters (like Python) and compilers (used for the C language). The C compiler (controlled by a program named cc ) translates C language statements into a program that uses the hardware-specific internal codes used by your computer. The operating system can then directly execute that resulting program. After you see the results of execution you might make changes, recompile and re-execute. This compilation step makes everything you do somewhat indirect. The compiler translates your C statements into another language which is then executed. This indirection makes compiled languages harder to learn; it also makes diagnosing a problem very hard.

Here’s a diagram that may help clarify how Python differs from a language like C. For a C programmer, they will use a complex IDE which includes the C Compiler to translate their C statements into a binary executable program from their statements. For a Python programmer, a simpler IDE uses the python program to execute the Python statements.

../_images/p1c5-fig3.png

C Compiler vs. Python

The binary executables have relatively direct control over the operating system and computer. A Python-language program controls Python.

Libraries. Python, the project, includes a rich set of supporting libraries. These libraries contain the basic gears, sprockets, flywheels and drive-shafts that you can use to make a program. By separating the library tool-boxes from the core language, the designers of Python could keep the language simple, which means the interpreter can be very efficient and reliable. Yet, they can provide an extensive feature set as separate extensions. Every new idea can be added as another extension.

There are other consequences to having extensive and separate libraries. Principally, good ideas can be preserved and extended, and bad ideas can be ignored. This basic evolution saves programmers from having to design everything perfectly the first time. As you get more experience with the Python programming community, you will see ideas come and go. Some extensions will blossom and become widely used, where others will be quietly ignored because something better has come along.

Another consequence of having separate libraries is that any programming project should begin with a survey of available libraries. This can replace unproductive programming with more productive research and reuse.

Development Environment. Finally, we see that Python also comes with a development environment, or workbench, that you can use to write and execute your Python statements. The integrated development environment ( IDE ) includes an editor for writing Python files, and the Python interpreter, plus some other tools for searching the Python libraries.

Interestingly, the Python development environment is just another Python program. When you double-click on the IDLE icon, you are starting a Python program that helps you write Python programs. At first, this seems like a real mind-wrenching problem. You might think of it as similar to asking “which came first, the chicken or the egg?” . It isn’t all that bad a problem however. In this case, someone else wrote IDLE to help you write your program. Your program, and IDLE (and a large number of other programs) all share the Python program as the driving engine.

Timeline. The Python programming language was created in 1991 by Guido van Rossum based on lessons learned doing language and operating system support. Python is built from concepts in the ABC language and Modula-3. For information ABC, see The ABC Programmer’s Handbook [Geurts91], as well as http://www.cwi.nl/~steven/abc/. For information on Modula-3, see Modula-3 [Harbison92], as well as http://www.modula3.org/.

The current Python development is centralized in Python.org. See http://www.python.org for the latest developments.

Coolness FAQ’s

If Python uses C, why not cut out the middleman and just learn C?
We have a number of reasons for avoiding C. First, programming in C is a more difficult proposition because of the number of tools involved: C uses a compiler to build programs: you don’t interact directly with C; you build a program, then interact with the operating system to run that program. Second, the C language is designed to make the C compiler work efficiently, it wasn’t designed to be easy to write or easy to read. Third, C exposes a number of house-keeping chores that professionals can exploit for efficiency; they won’t help newbies get their first program written.
If Python is so cool, why doesn’t everyone use it?

That’s like asking why everyone doesn’t like the Boston Red Sox, Philly cheese steaks, and the Red Hot Chili Peppers. Some people prefer Mom, Apple Pie and the Beatles. There’s really no accounting for taste.

Some languages like Visual Basic and C# have the powerful and sophisticated marketing arm of Microsoft backing them. Other languages, like Java, have Sun backing them, and a large, well-established open-source community.

Some languages, like COBOL, are entrenched in the way data is processed at large organizations. While Python may be superior, it appears cheaper (in the short run) to leave the COBOL programs in place rather than convert them to something less complex and less expensive to operate and maintain.

The most important reason, however, is that languages are often specialized around particular tasks or data structures. Some languages, like SQL, express some operations more precisely and with a useful level of abstraction.

Table Of Contents

Previous topic

Two Minimally-Geeky Problems : Examples of Things Best Done by Customized Software

Next topic

Instant Gratification : The Simplest Possible Conversation

This Page