opment and maintenance, particularly in large projects, where many developers
cooperate and often maintain code originally written by others.
Python is simple, but not simplistic. It adheres to the idea that, if a language behaves
a certain way in some contexts, it should ideally work similarly in all contexts.
Python also follows the principle that a language should not have “convenient”
shortcuts, special cases, ad hoc exceptions, overly subtle distinctions, or mysterious
and tricky under-the-covers optimizations. A good language, like any other well-
designed artifact, must balance such general principles with taste, common sense,
and a high degree of practicality.
Python is a general-purpose programming language: Python’s traits are useful in
just about any area of software development. There is no area where Python cannot
be part of a great solution. “Part” is an important word here; while many developers
find that Python fills all of their needs, it does not have to stand alone: Python pro‐
grams can cooperate with a variety of other software components, making it an
ideal language for gluing together components written in other languages. One of
the language’s design goals was that it should “play well with others.”
Python is a very high-level language (VHLL). This means that Python uses a higher
level of abstraction, conceptually further from the underlying machine, than do
classic compiled languages such as C, C++, and Fortran, which are traditionally
called “high-level languages.” Python is simpler, faster to process (both for human
brains and for programmatic tools), and more regular than classic high-level lan‐
guages. This enables high programmer productivity and makes Python an attractive
development tool. Good compilers for classic compiled languages can generate
binary machine code that runs faster than Python code. However, in most cases, the
performance of Python-coded applications is sufficient. When it isn’t, apply the
optimization techniques covered in “Optimization” on page 477 to improve your
program’s performance while keeping the benefit of high productivity.
Somewhat newer languages such as Java and C# are slightly higher-level than classic
ones such as C and Fortran, and share some characteristics of classic languages
(such as the need to use declarations) as well as some of VHLLs like Python (such as
the use of portable bytecode as the compilation target in typical implementations,
and garbage collection to relieve programmers from the need to manage memory).
If you find you are more productive with Java or C# than with C or Fortran, try
Python (possibly in the Jython or IronPython implementations, covered in “Python
Implementations” on page 5) to become even more productive.
In terms of language level, Python is comparable to other powerful VHLLs like
JavaScript, Ruby, and Perl. The advantages of simplicity and regularity, however,
remain on Python’s side.
Python is an object-oriented programming language, but lets you develop code
using both object-oriented and procedural styles, and a touch of functional pro‐
gramming, too, mixing and matching as your application requires. Python’s object-
oriented features are conceptually similar to those of C++, but simpler to use.
4 | Chapter 1: Introduction to Python