# Python Course

Previous Chapter: History and Philosophy of Python
Next Chapter: Interactive Mode

## Why Python?

There are many good reasons to choose Python as your primary programming language. First of all Python is an easy to learn, powerful programming language. Furthermore it has efficient high-level data structures, which allow you to write complex operations in fewer statements than in C, C++ or Java.
Object-oriented programming is a lot easier than in languages like Java.
Python has become one of the most popular programming languages among developers and programmers. They praise it for its clean syntax and code readability. Python is a general-purpose high-level programming language. Python is both object oriented and imperative and it can be even used in a functional style as well. Python programs are portable, i.e. they can be ported to other operating systems like Windows, Linux, Unix and Mac OS X, and they can be run on Java and .NET virtual machines.
David Beazley says in his foreword to the book "How to Think like a Computer Scientist Learning with Python" by Jeffrey Elkner, Allen B. Downey, and Chris Meyers: Despite Python's appeal to many different communities, you may still wonder "why Python?" or "why teach programming with Python?" Answering these questions is no simple task-especially when popular opinion is on the side of more masochistic alternatives such as C++ and Java. However, I think the most direct answer is that programming in Python is simply a lot of fun and more productive.
Guido van Rossum, the author of Python, began work on Python at the National Research Institute for Mathematics and Computer Science in the Netherlands (Centrum voor Wiskunde en Informatica, CWI).
When asked, what features of Python he is most pleased with, Guido van Rossum said in an interview with Linux Journal: "The feel of the whole system suits my style of programming well, for obvious reasons. The ability to run the interpreter interactively and the ability to write code from the bottom up and test it piecemeal combine to let me write code quickly. Other people find that it makes them more productive, too." (LJ, no 55)
Python is very fast. The source code is compiled into bytecode, so that executing the same file will be faster, if the script will be executed again. The bytecode is an "intermediate language", which is said to run on a virtual machine that executes the machine code corresponding to each bytecode.

## Comparing Python with Java, Perl and other Programming Languages

Prof. Lutz Prechelt from the University of Karlsruhe compared Python with other programming languages. He summarises his results: "80 implementations of the same set of requirements are compared for several properties, such as run time, memory consumption, source text length, comment density, program structure, reliability, and the amount of effort required for writing them. The results indicate that, for the given programming problem, which regards string manipulation and search in a dictionary, 'scripting languages' (Perl, Python, Rexx, Tcl) are more productive than 'conventional languages' (C, C++, Java). In terms of run time and memory consumption, they often turn out better than Java and not much worse than C or C++. In general, the differences between languages tend to be smaller than the typical differences due to different programmers within the same language. (see Lutz Prechelt, An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tcl, IEEE Computer, Vol. 30, (10), p. 23-29, Oct 2000.)

## Other Advantages of Python

It's surprisingly easy to embed Python, or better the Python interpreter into C programs. By doing this you can add features from Python that could take months to code in C. Vice versa, it's possible to extend the Python interpreter by adding a module written in C. One reason to do this is if a C library exists that does something which Python doesn't. Another good reason is if you need something to run faster than you can manage in Python.

The Python Standard Library contains an enormous number of useful modules and is part of every standard Python installation. After having learned the essentials of Python, it is necessary to become familiar with the Python Standard Library because many problems can be solved quickly and easily if you are acquainted with the possibilities that these libraries offer.

Previous Chapter: History and Philosophy of Python
Next Chapter: Interactive Mode