Python Renaissance

Python is enjoying a sort of renaissance – and I am not talking about all those foundling pet pythons in the swamps of Florida. This open source, cross  platform programming language has been popular in academic circles for its simple  syntax but robust functional programming.  Here is the the key philosophy of Python:

 “PEP 20 (The Zen of Python)”, which includes aphorisms such as:

  • Beautiful is better than ugly.
  • Explicit is better than implicit.
  • Simple is better than complex.
  • Complex is better than complicated.
  • Readability counts.

Rather than requiring all desired functionality to be built into the language’s core, Python was designed to be highly extensible. Python can also be embedded in existing applications that need a programmable interface. This design of a small core language with a large standard library and an easily extensible interpreter is Python’s key characteristic

The result has seen Python maintains a high position in measures of the popularity of language. Here is its 6th ranking at Langpop.com:
pythonpop
langpop.com measures all the references to programming languages at websites like Yahoo Search, Freshmeat, and Craigslist.org

Tiobe does a similar measure of popularity and has Python’s history over the past decade:
tpci_trends
But Tiobe also is careful to describe how its index is created. “The TIOBE Programming Community index is an indicator of the popularity of programming languages. The index is updated once a month. The ratings are based on the number of skilled engineers world-wide, courses and third party vendors. The popular search engines Google, Bing, Yahoo!, Wikipedia, Amazon, YouTube and Baidu are used to calculate the ratings. Observe that the TIOBE index is not about the best programming language or the language in which most lines of code have been written.”

Note that Python peaked in mid 2004 but has slowly moved up in popularity to match Visual Basic and PHP.  Note also  how Objective C has risen dramatically in popularity since the emergence of the iPhone and iPad.

The Python Tradeoff

The advantage of an interpreted language that is easy to program is that it not only is easy to teach but it gets ported everywhere. But the following benchmark shows the fundamental tradeoff of ease of programming versus performance and  speed:
pythonbench

Python consistently uses less less memory and requires less code than one of the  most popular programming language, Java. However, except for a few cases, Python runs 30-60 times slower than Java [and Java itself runs 2-3 times slower than C and requires 10-20 times more memory – see here].  But extensibility is a key feature of Python so there are several languages that convert Python [or subset Python] to Java – Jython, .NET – Iron Python, and  JavaScript – Pyjamas.

This JavaScript connection is not the only web use of Python as more commercial  hosting providers include Python among their development languages.  But the following comparison of Python versus JavaScript is most revealing:
pythonbenchjs
Python still has a notable speed disadvantage with JavaScript but no longer has the memory or code size advantage as it does in the case of Java. However, like JavaScript, Python has a mixed reputation for web programming security. So perhaps the decider between the two languages will be the tools and libraries available.

Tools and Uses

Because of Pythons extensibility it has been adapted for a wide range of uses. For example, in the mobile arena Nokia developed Psy60 for its Symbian OS where it was used extensively. More recently Appcelerator and MoSync have IDEs which support mobile development using Python. Also in the fast advancing General Purpose GPU programming, Python has secured a position with its CUDA and WebCL integration. And as previously noted, many Web Hosting services provide Python for  Web application frameworks like DjangoPylonsPyramidTurboGearsweb2pyTornadoFlask and Zope which support developers in the design and maintenance of complex applications.

There are a number of IDEs available for Python development with Eclipse and Komodo among the major development tools. However, because Python is so open be careful to match your version of Python to be used with the chosen IDE. The net result has been the development and use of Python for serious applications such as video + computational graphics that are used in many popular movies, Biochemical modeling and Hacker/Security development among others.

If you are interested in doing more with Python start here. But also there are two college level but free courses on Python and programming – both at Coursera.org. The UofT has a basic programming design course that uses Python and Georgia Tech has a course in which Python is used extensively in Computational Photography.  Both are well worth checking out.

Summary

Python has made its reputation on being a simple to use programming language which its benchmark results largely confirm. However, don’t be fooled Python supports advanced features like Classes and Functional programming. It also has an extensive core library with scores of popular extensions. It’s support of Web development and GPGPU programming show that it has a a future look as well. Again, to see examples of Python code, go here.