Python Introduction

Chapter 1 9 mins

Learning outcomes:

  1. What is Python
  2. The history of Python
  3. Implementations of Python

What is Python?

Python is an interpreted, multiparadigm, general-purpose programming language, created by the dutch programmer, Guido van Rossum, in 1991.

Guido van Rossum — the creator of Python
Guido van Rossum — the creator of Python (Daniel Stroud, CC BY-SA 4.0, via Wikimedia Commons)

Python is one of the most popular programming languages in use, due to its simplicity, extensibility and capability. It powers desktop as well as web applications.

It is a high-level language that favours code readability by abstracting away many tedious programming details. It's based on the offside rule whereby blocks of code are denoted using an increased level of indentation (as compared to curly brackets).

Logo of Python (www.python.org, GPL, via Wikimedia Commons)

Python is well-known in the field of data science and machine learning. It has huge support for graphical and mathematical analysis, with a lot more feature to offer, that makes it a really good choice for mathematicicans and data scientists.

Talking about its learning curve, Python is exceptionally easy to learn. One can start his/her programming journey with Python — it's that easy!

The basics can be understood in less than a day, but obviously remembering them and working with more advanced topics requires time and experience.

The history of Python

Back in the late 1980's, interest prevailed in a Dutch programmer of developing a scripting language that could easily interface with the Amoeba OS. What started off as a fun project in Christmas holidays was to become a milestone in the coming future.

Guido van Rossum, the creator of Python, was working at CWI (Centre Wiskunde and Informatica) on the Amoeba OS when he felt the need of a programming language that could easily work with the OS.

He conceived of a language similar in syntax to the ABC programming language (developed by a team that included Guido as well) that could be reachable to non-techy people.

Finding the coming Christmas holidays as the high time to work on this idea, he decided to give it a try. Guido began working on a programming language on his own.

In the back of this mind, he had the language ABC. He wanted to use the good aspects of ABC in this new language, while improve on those that really frustrated him.

The good aspects that Guido wanted to keep were its ease of use for novice computer users; its high-level data types (though he shuffled their details a bit in Python); and its use of indentation to denote blocks of statements, a.k.a the offside rule.

Amongst the frustrating aspects of ABC were its lack of extensibility. It was nearly impossible for developers to add their own modules to the language in C or C++. Not only this, but ABC also didn't have good support for exception handling. Keywords were in uppercase, making them particularly difficult to type. Moreover the language didn't have a strong I/O mechanism. Considering all these downsides, Guido desired making this new language free from all of them.

Now he had to come up with a name for this new project. Guido wanted something unique and short. The British comedy series, 'Monty Python's Flying Circus', really amazed him and eventually led him to name the language 'Python'.

A big project was about to begin...

The first version of Python was officially released in 1991 under the version 0.9.0. Just by this first release, Python came to prominence as a simple and versatile programming language.

It had a solid foundation — offering classes, an inheritance model, exception handling, modules, and much more — and the ability to be extended by developers using C or C++.

By version 1.0, Python got lambdas, map and filter functions that blended a functional programming style into the language. These features were coded by a Lisp programmer who wished having them in this new language.

Python 2.0 was released under BeOpen PythonLabs. It had many new features to offer including list comprehensions and a reference-counting garbage collector.

Perhaps the major advancement to Python came from the release of Python 3.0. It changed many of the old features in Python 2.0, most notably the print statement, which was now the print() function.

Python 3's motive was to remove duplicates from the language in lieu of their principle "There should be one, and only one, way to do something". It is not completely backwards-compatible to version 2.0.

Today, both versions are available, although it's preferred to code in Python 3, as it's on the current charts of the Python developing team, receiving active updates and bug fixes. Support for Python 2 has officially ended.

To boil it all down, Guido began working on Python, never really thinking that it would receive such a fame in the coming future. Sometimes small projects revolve around ideas that make them the origin of milestones in the future. Python is a living example.

Implementations of Python

The core Python language is basically a set of rules, statements, structures, disciplines, data types, and so on. In fact, every programming language follows this notion.

The language is itself an idea — it doesn't get running until it is implemented.

The implementation of a programming language is a computer program that can understand a piece of text written in that particular language and do something useful out of it.

The implementation of a programming language is itself written in a programming language. Some implementations are written using assembly languages while other are written in a bit higher-level, but still relatively low-level, languages.

Without an implementation, a programming language is similar to a car without an engine. The car is useless without the engine!

Every language has an implementation; some have more than one.

For example, JavaScript has four different implementations on each of the four major browsers: Chrome, Safari, Edge (former Internet Explorer), and Firefox. Each implementation differs from the other in how it enables each feature of the language — how it manages I/O, how it collects garbage, how it allocates memory to data and so on.

The V8 engine for Chrome is an extremely powerful implementation of JavaScript, written in C++ that eventually gave birth to the server-side variant of JS — NodeJS.

Coming back to Python, it also has a couple of implementations.

The original one, and by far the most common, is CPython. As the name might suggest, CPython is mainly written in C; with modules programmed in Python itself.

Another common implementation is PyPy, which is known for its speed over CPython. It uses a JIT (Just In Time) compiler.

Some other implementations include Jython, written in Java; IronPython, written for the .NET framework; Stackless Python, written in C, but avoiding the hassle of stacks; and so on.

Each has its own uses, pros and cons. It's not really a good-vs-bad comparison — rather it's a comparison based solely on usage.

If you're a Java developer, then Jython might fit your taste since it'll be easier for you to add Java modules to Python using it. Similarly, if you're developing a .NET application, IronPython would be particularly handy.