Tuesday, 3 January 2017

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."

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.

History of Python

The history of Python starts with ABC. This doesn't mean the "American Broadcasting Company" nor the New Wave band ABC, but the programming language ABC. ABC is a general-purpose programming language and programming environment, which had been developed in the Netherlands, Amsterdam, at the CWI (Centrum Wiskunde & Informatica). The greatest achievement of ABC was to influence the design of Python.

Python was conceptualized in the late 1980s. Guido van Rossum worked that time in a project at the CWI, called Amoeba, a distributed operating system. He programmed in ABC. In an interview with Bill Venners (January 2003), Guido van Rossum said: "I remembered all my experience and some of my frustration with ABC. I decided to try to design a simple scripting language that possessed some of ABC's better properties, but without its problems. So I started typing. I created a simple virtual machine, a simple parser, and a simple runtime. I made my own version of the various ABC parts that I liked. I created a basic syntax, used indentation for statement grouping instead of curly braces or begin-end blocks, and developed a small number of powerful data types: a hash table ( or dictionary, as we call it), a list, strings, and numbers."

So, what about the name "Python": Most people think about snakes, but the name has something to do with excellent Britisch humour. Guido van Rossum, the creator of Python, wrote in 1996 about the origin of the name of his programming language: "Over six years ago, in December 1989, I was looking for a 'hobby' programming project that would keep me occupied during the week around Christmas. My office ... would be closed, but I had a home computer, and not much else on my hands. I decided to write an interpreter for the new scripting language I had been thinking about lately: a descendant of ABC that would appeal to Unix/C hackers. I chose Python as a working title for the project, being in a slightly irreverent mood (and a big fan of Monty Python's Flying Circus)."