Whereas Python was invented initially as a successor to ABC language merely as a “hobby” programming project (which would attract Unix/C hackers) for the author who named it after the series of his biggest star Monty Python.Perl was just nearly around 2 years earlier as a Unix scripting language which intended to make report processing easier. It was a mixture of combination of many languages including C, awk, sed and shell script.
The thing which is worth noting is that these languages which evolved of different intentions are being constantly compared, which has made me study and figure out the reasons, of which some important ones are listed as below:
- Both targeted Unix Operating System, one for hackers and other to process reports.
- Both are object oriented (Python being the more) and interpreted, with one being strongly typed and clear when it comes to coding i.e. Python, and other allowing ugly typing with braces for representing a block i.e. Perl
- Both are opposite in principle when we say, Perl has many ways of doing a single task while python focuses on one and only one way of doing things.
- Python takes huge advantage over Perl when it comes to code readability. Python’s code is lot more cleaner to understand than that of Perl even when reading code after years.With indentation representing the block of code, and proper structuring, Python’s code is a lot more cleaner. On other hand Perl borrows its syntax from various programming languages like: C, shell scripting and even awk and sed filters when it comes to regular expressions.
Python takes huge advantage over Perl when it comes to code readability. Python’s code is lot more cleaner to understand than that of Perl even when reading code after years.With indentation representing the block of code, and proper structuring, Python’s code is a lot more cleaner. On other hand Perl borrows its syntax from various programming languages like: C, shell scripting and even awk and sed filters when it comes to regular expressions.
Python PROS:
Has a clean and elegant syntax which makes this language a great choice as first programming language for novices who want to have a hands-on on any programming language.
Has very advanced and inherent OO Programming, also thread programming in Python is way better than Perl.
There are many application areas where Python is preferred and even it outperforms Perl. Like: Perl is preferred for CGI scripting but now a days Python’s Django and web2py like web scripting languages are becoming more popular and have huge attraction from the industry.
Has several SWIG wrappers for different programming languages like: CPython, IronPython and Jython and development of these has preceded the development of SWIG wrappers for Perl.
Python code is always well indented and easy to read and understand even if you are reading someone else’s code or even your code after years.
Python is good for various applications like: Big Data, Infra Automation, Machine Learning, NLP etc, is has huge support of active communities because of being Open Source.
Perl PROS:
Perl has powerful one liners and even ensures UNIX piping like syntax which can be used on command line to perform various tasks, also it is influenced by Unix and its command line programming so integrates many UNIX influenced commands in its coding.
Perl is known for its powerful regex and string comparison operations as it is influenced by sed and awk like powerful UNIX tools. In case of regex and string operations like: substitution, matching, replacement, Perl outperforms python which would take few lines of code to achieve the same. Also many file I/O operations, exception handling are done faster on Perl.
When it comes to a language for report generation, Perl has always been in the fame since its introduction as one of the main reasons for author to develop language like Perl was for report generation.
Many application areas where Perl finds its use are Network Programming, System Administration, CGI Scripting (here Python is overcoming Perl with Django and web2py) etc.
As seen above where both languages are good on their regard as per the applications they target, Python takes a bit of advantage over Perl as a first choice for a novice due to its clean and easy to understand code, where as on other hand Perl outperforms Python when it comes to string manipulation operations and some advanced one liners for UNIX like OS and various other operations it is known for.
Perl is better. May not be easier but better.
Perl has almost no constraints. It’s philosophy is that there is more than one way to do it (TIMTOWTDI, pronounced Tim Toady).Python artificially restricts what you can do as a programmer. It’s philosophy is that there should be one way to do it. If you don’t agree with Guido’s way of doing it, you’re shit out of luck.
Basically, Python is Perl with training wheels. Training wheels are a great thing for a beginner, but eventually you should outgrow them. Yes, riding without training wheels is less safe. You can wreck and make a bloody mess of yourself. But you can also do things that you can’t do if you have training wheels. You can go faster and do interesting and useful tricks that aren’t possible otherwise. Perl gives you great power, but with great power comes great responsibility.
A big thing that Pythonistas tout as their superiority is that Python forces you to write clean code. That’s true, it does… at the point of a gun, sometimes at the detriment of simplicity or brevity. Perl merely gives you the tools to write clean code (perltidy, perlcritic, use strict, /x option for commenting regexes) and gently encourages you to use them.
Perl gives you more than enough rope to hang yourself (and not just rope, Perl gives you bungee cords, wire, chain, string, and just about any other thing you can possibly hang yourself with). This can be a problem. Python was a reaction to this, and their idea of “solving” the problem was to only give you one piece of rope and make it so short you can’t possibly hurt yourself with it. If you want to tie a bungee cord around your waist and jump off a bridge, Python says “no way, bungee cords aren’t allowed”. Perl says “Here you go, hope you know what you are doing… and by the way here are some things that you can optionally use if you want to be safer”