The Python Programming Language
From large organizations to multi decades expert programmers as well as new ones, Python has gained a huge adoption which is growing even more in recent years. Let's see together why
Python is a computer programming language first appeared on the scene 28 years ago (on February 20, 1991). It is an interpreted, high-level, general-purpose, dynamically typed, object-oriented, imperative, functional and procedural programming language with automatic memory management whose main purposes are: enable the writing of code with great readability, allow small and large scales software development, offer easy portability across diffent hardware/operating systems.
The means by which the language created by Guido van Rossum achieves its goals are:
- the great code readability derives from Python atypical and unique syntax. In Python blocks of semantically grouped code are not delimited by curly braces or special keywords (like “begin/end”) but by indenting and outdenting the lines of code.
- Python has a comprehensive and pragmatic standard library focused on day-to-day common programming tasks. Together with it's syntactic peculiarities, even the development of large scale software is greatily eased.
First glance at the code
Example: The classic "Hello world" program written in Python:
Main features of Python
Python type system is dynamic. Objects are typed but variables have no type associated to them, and even if from Python 3.5 the syntax of the language allows specifying static types, these are not checked at runtime. During the execution Python uses dynamic name resolution (late binding) to execute methods and to access objects variables. Anyway Python is strongly typed and forbid automatic computation between different types if not explicity programmed, like adding a number to a string.
While Python type system is completely extensible, it offers many high level built-in data types that can be grouped into numerics, sequences, mappings, classes, enumerations (since version 3.4), instances and exceptions. Integer types have bits sizes that are implementation and platform dependent and from version 3.x have non-limited lengths.
|bytearray||sequance of bytes||mutable|
|bytes||sequance of bytes||immutable|
|complex||complex number (has real and imaginary parts)||immutable|
|dict||dictionary of key/value pairs of arbitrary types (keys must be hashable)||mutable|
|ellipsis||used as index in arrays||-|
|float||floating point number, system-dependent precision||immutable|
|frozenset||unordered set of elements of arbitrary types with no duplicates||immutable|
|int||non-limited length integer||immutable|
|list||list of elements of arbitrary types||mutable|
|set||unordered set of elements of arbitrary types with no duplicates||mutable|
|str||sequence of Unicode characters||immutable|
|tuple||can contain elements of arbitrary types||immutable|
Python is object-oriented and supports multiple inheritance. A class can inherit characteristics and features from one or more classes or even from primitive types. Classes are themselves instances of the metaclass type allowing metaprogramming and reflection.
Memory management in Python is automatic. A cycle-detecting reference-counting garbage collector provides to free at run-time the memory resources that become not reachable any more by any part of the running application.
The Python Standard Library and more
One of the key strengths of Python lies in its Python Standard Library. Not only this big library frees programmers from differences and details of individual systems easing cross-platform software develoment, it's also very pragmatic and focused on a lot of real day-to-day programming needs. A part from the standard library, the official repository for third-party Python software, the Python Package Index, adds more than 100,000 other packages to the Python programmer's toolset, covering any sort of functionality a programmer can dream of like graphical user interfaces, web frameworks, multimedia, databases connectivity, networking, system administration, scientific computing, text and image processing and many others.
Being an interpreted language Python execution performance is aligned to other interpreted languages such as PHP and Ruby, meaning that Python programs run slower than C/C++ or even Java ones. Despite this, under certain conditions it is preferable to use Python even when a higher execution speed is necessary. Python programmers can in fact move time-critical functions to extension modules written in C, with which Python interfaces very easily, or use a just-in-time compiler instead of the default interpreter, or completely transpile Python sources into C and make direct C-level API calls from the program. By embracing the easiness of Python programming where speed in not important with the power of C execution in those parts where speed is critical, the resulting programs can achieve the best of both worlds: execution speed comparable to languages that compile directly to native machine code, and the easiness of programming typical of a very high level language like Python is.
Free and open source
Python is open source software as it's always been since it's first release in 1991. It's license is GPL-compatible making it suitable for both GPL, other open source license types as well as closed source and commercial ones. CPython, the reference implementation of Python, is managed by the non-profit Python Software Foundation, which is also responsable for the advancement of the language. The model by which the develpment is handled is community-based and its primary mechanism consists in the Python Enhancement Proposal (PEP) process, used to propose new features, collect community input on issues and document Python design decisions. Important PEPs are reviewed and commented on by the Python community and by Guido Van Rossum himself, who still remains Python's principal author and contributor as the playful title, Benevolent Dictator For Life (BDFL), given to him by the Python community cleary reflects.
Guido van Rossum, the creator of Python, was a big fan of Monty Python's Flying Circus, a British sketch comedy series created by the comedy group Monty Python. In December 1989, tired of some ABC programming language peculiarities and after several months of thinking about a successor to that language, he started to work to a new language and decided to call it Python aimed at putting as much fun and irreverence as possible in his work. Python's philosophy is based on concepts like beauty, simplicity, readability and above all fun. This mood, together with Python uniquenesses and strengths, contributed to grow during the decades a huge community of programmers and hackers who still today consider an important goal to keep the language fun to use. Pythonists, as admirers of Python like to be called, also use neologisms like pythonic to designate code that emphasize the minimalist approach to programming and great readability of the language, and objects and idioms like the ones usually present in the original Monty Python comedies are often used in Python tutorials and sample code.
Today (2018) Python is one of the top four most adopted programming language of the world, and is used as the main development language for a huge amount of software developments from web applications to scientific computing, from video games to algorithmic trading and quantitative finance, from image processing to statistical calculations with 2D/3D visualization. Thanks to its great abilites to interface to C/C++ it's very often used as the official scripting language of well known and widely adopted software applications like 3D animation softwares such as 3ds Max, Blender, Cinema 4D, Lightwave, Houdini, Maya and many others, or provides the official interface to Artificial Intelligence and Deep Learning packages like TensorFlow from Google.
Increasing demand for Python programmers
In the past 5 years Python has enjoyed one the largest growth rate in terms of number of queries in the major search engines. While already in 2016 a software engineer with good Python knowledge could earn up to $100,000, analysts predict that an annual salary of a Senior Python Developer will fluctuate around the amount of $105,000 and higher. This is due in large part to the increasing adoption of the language by big organizations both for internal development and for interfacing to external libraries/services like Google App Engine which first of the three available programming languages to program with is Python.
Notable softwares/platforms/products written in Python
- Instagram is written in Python
- Reddit is written entirely in Python
- Quora is another famous site written in Python
- Dropbox uses a Python framework to program communications between computers
- at Google, python is one of the 3 "official languages" alongside with C++ and Java, which means software developed in Python is allowed to deploy to production services.
- Raspberry Pi, the most popular small single-board computer of the world, has Python as its first and most suggsted programming language. The Pi in the name of the SBC even comes from Python itself
- Wikipedia, Yahoo!, CERN, NASA and many other big organizations adopt Python for many parts of their IT infrastructure
After almost 30 years from its first release, Python is still seeing, and notably during the last 5 years, an important increasing in popularity at the point that the TIOBE index ranks it as one of the four most popular programming languages of the world. Python's wide success is surely due to its simplicity, its peculiar syntax that allows to write very readable code and its comprehensive and cross-platform standard library. Still, as we see it, two are the really killer features that made Python get where it is today and that will boost it even more in the future: 1) the ease with which Python can interface with C/C++; 2) the ease with which Python can be transpiled to other languages and/or virtual machine bytecodes. While these two features are certainly not exploited very often, they are by far and large the most strategically important ones when evaluating the language adoption. In fact being cross-platform today means more that just being able to run applications on many different hardware/operating systems, transpiling between different languages to leverage the power of all the software assets at disposal of an organization is becoming increasingly in use these days and languages like Python that play well in these regards are certainly more suited to have a bright future.