Can Python Replace Perl In Most Cases?

28/10/2015 15:02

Python application developmentPerl and Python are both scripting languages with object oriented programming capabilities and are available in most platforms and as such they target similar if not the same pool of developers world-wide which brings up the comparison and the competition. Now the question is, can Python upstage Perl and take its place in most cases? To answer this question, it would be necessary to look at the strengths and weaknesses of both Perl and Python, evolution of the two languages and the emerging indicators of preference in the developer community.

Perl

Perl was originally developed by in 1987 by Larry Wall as a Unix scripting language and has since evolved, developing capabilities for graphics programming, system administration and network programming among others. Perl was initially used for its powerful text processing capability but in the late 90s it gained popularity as a CGI (Common Gateway Interface) scripting language as the Internet began to grow exponentially. According to Wikipedia1, “in 1998, it was also referred to as the duct tape that holds the Internet together, in reference to both its ubiquitous use as a glue language and its perceived inelegance”. The “perceived inelegance” here refers to the fact that Perl is bit too flexible when it comes to syntax and code structuring which in turn arises from the Perl dictum (articulated by Larry Wall ) “ There is more than one way to do it” , abbreviated to TMTOWTDI. However, Perl's popularity was so immense that it spawned a culture and a community, members of which contribute code, participated in discussions and development and worked as Perl evangelists. CPAN or Comprehensive Perl Archive Network is one of the largest repository of code and one of the major advantages in using Perl. But, the fact remains that Perl is no longer as popular after it started facing competition from new languages such as Ruby and of course Python.

Python

Python was first implemented by in 1989 by Guido Van Rossum but became more popular after the release of the second version Python 2.0 in 2000. Van Rossum named the language Python as homage to Monty Python's Flying Circus2, of which he was a great fan but it also implied that the language was meant to bring fun to programming, something which echoes Perl's philosophy too. However, the aphorisms listed in the Zen of Python encapsulating core Python philosophy are clearly opposed to Perl's motto and philosophy. For instance, while Perl motto says “There is more than one way to do it”, Python philosophy emphatically rejects it, stating “There should be one-- and preferably only one --obvious way to do it.” Nearly all aphorisms in PEP 20 document are in stark opposition to Perl paradigm and conventions. After all, Python is known for being highly readable language with clearer syntax and coding convention and requiring lot fewer lines of code to create applications as compared to other popular programming languages. For instance, use of whitespace indentation instead of syntactic symbols like curly braces or semi-colon to indicate scope reads more like human language rather than programming language. This is especially important in contrast to Perl which is known for syntax that makes its code difficult to read. With a host of good libraries Python is now equipped with, it can perform nearly every task that Perl has been used to accomplish. Python application development also supports a number of GUI cross-platform frameworks, something which Perl is not really known for.

However, it is not really the difference in languages but adoption by developers that would decide if Python is gaining popularity at the cost of Perl. Currently, Python ranks on the 5th position in TIOBE Index4 while Perl ranks at 11th position clearly indicating a consistent decline in popularity over the decade. Also web search by users in context to programming languages in case of Perl has dwindled from 10% in 2005 to 2% from 2011 onward. A number of reasons could be attributed  to decline of Perl starting with the fact that the way companies do business has changed significantly since the days, Perl was considered the duct tape that holds Internet together. But more importantly there are strong indications that developers, mostly new but also older ones are choosing Python over Perl both for the former's neater structure and powerful capabilities. Python syntax and language structure makes it easier for new developers to pick it up faster than they would when learning Perl. Further, when working with existing codebase it becomes difficult to understand because of Perl code's notorious “line noise” complicated by the fact that since there are more than one ways to do it, the person reading the code may face difficulty understanding why a certain block has been coded in a certain way. This can be quite taxing in maintenance and upgrading projects. 
Python doesn't have a huge centralized repository like CPAN but it has spawned communities of users who are more or less contributing in a similar manner to provide support to users taking up Python as their language of choice. Already a number of GUI libraries and frameworks are being used extensively for rapidly prototyping and developing applications, an area where Perl seems to be lagging behind. Ironically, Python's popularity may be one of the factors drawing more developers towards it, especially young, enthusiastic programmers who can in the long run enrich the Python ecosystem. Further, Python being included in Linux distributions and supported by nearly all operating systems exposes the language to students at a very early stage. However, Perl does have a core userbase that is loyal to the language almost religiously and some continue to evangelize on community website such as PerlMonks, while others simply find Perl superior to other languages and are unlikely to switch over.  So, while it is unlikely that Perl would entirely be replaced by Python, the latter is most likely to become the dominant language in most cases where traditionally Perl occupied the top position.       
Mindfire Solutions has rich experience in developing dynamic websites, custom web applications and Desktop Applications in Python and Django. With an 8 year track record of consistently wowing customers hailing from various industries and geographies, Mindfire Solutions is the Python development company, you were searching for.