Dive Deep Into Python Vs Perl Debate – What Should I Learn Python or Perl?

Often when a new programming language is introduced, there is a debate that starts amongst some of the genius minds in the industry wherein the language is compared with the one already spreading its roots. A kind of buzz often spreads in the IT industry and the new one is often compared on every aspect may it then be features, syntax or core CPU and memory aspects including GC time and all, with the existing one of its kind.

Many examples of such cases can be picked up and investigated from the past including the debate between Java and C#, C++, etc. One such case which drew a significant amount of attention was the debate between two languages which came out one after the other in a short span i.e. Python and Perl.

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.

Suggested Read: Getting Started with Python Programming and Scripting in Linux

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 a 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:

  1. Both targeted Unix Operating System, one for hackers and others to process reports.
  2. 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
  3. 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 vs Perl – Features Compared

Let’s dive deep into this debate and try to figure out the overall aspects where these two languages differentiate from one another. Also, let’s try finding out the source of truth for many cliches which can be heard in the industry saying “Python is Perl with training wheels” or “Python is similar to Perl but different” so that we can try and conclude with an accurate solution to this never-ending debate.

1. Python’s Clean vs Perl’s Complex Syntax

Python takes a huge advantage over Perl when it comes to code readability. Python’s code is a lot clearer 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 cleaner. On the 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.

Suggested Read: 15 Useful ‘sed’ Commands for Daily Linux System Administration Tasks

Apart from this, with ‘{‘ and ‘}’ representing a block of code and unnecessary addition of ‘;’ at the end of each line, code in Perl could become a problem to understand if you read it after months or years because of its allowance of ugly scripting.

2. Perl’s Built-in Vs Python’s 3rd Party Regex and OS Operations Support

Perl language borrows its syntax from C and other UNIX commands like sed, awk, etc. due to which it has way powerful and built-in regex support without importing any third-party modules.

Also, Perl can handle OS operations using built-in functions. On the other hand, Python has third-party libraries for both the operations i.e. re for regex and os, sys for os operations which need to be ensured before doing such operations.

Perl’s regex operations have ‘sed’ like syntax which makes it easy not only for search operations but also replace, substitute and other operations on a string can be done easily and swiftly than python where a person needs to know and remember the functions which cater to the need.

Example: Consider a program to search for a digit in the string in Perl and Python.

Import re
str = ‘hello0909there’
result = re.findall(‘\d+’,str)
print result
$string =  ‘hello0909there’;
$string =~ m/(\d+)/;
print “$& \n”

You see the syntax for Perl is way easy and inspired by sed command which takes advantage over Python’s syntax which imports third party module ‘re’.

3. Python’s Advanced OO Programming vs Perl’s One-Liners

One feature where Python overshadows Perl is its advanced OO programming. Python has extensive object-oriented programming support with clean and consistent syntax while the object OOP in Perl being outdated where the package is used as a substitute for classes.

Suggested Read: Getting Started with Python Django Web Framework

Also, writing OO code in Perl will add a lot more complexity to the code, which would eventually make code difficult to understand, even subroutines in Perl are very difficult to program and eventually difficult to understand later.

On the other hand, Perl is best for its one-liners which can be used on the command line for performing the various tasks. Also, Perl code can eventually do various tasks in fewer lines of code than python.

A shortcode example of both languages which highlights Perl ability to do more in less LOC:

with open(“data.csv”) as f:
for line in f:
print line,
except Exception as e:
print "Can't open file - %s"%e
open(FILE,”%lt;inp.txt”) or die “Can’t open file”;
while(<FILE>) {
print “$_”; } 

Pros and Cons – Python vs Perl

In this section, we will discuss the Pros and Cons of Python and Perl.

Python PROS:

  1. It has a clean and elegant syntax which makes this language a great choice as the first programming language for novices who want to have hands-on on any programming language.
  2. Has very advanced and inherent OO Programming, also thread programming in Python is way better than Perl.
  3. There are many application areas where Python is preferred and even it outperforms Perl. Like: Perl is preferred for CGI scripting but nowadays Python’s Django and web2py like web scripting languages are becoming more popular and have a huge attraction from the industry.
  4. 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.
  5. 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.
  6. Python is good for various applications like Big Data, Infra Automation, Machine Learning, NLP, etc, it has huge support of active communities because of being Open Source.

Python CONS:

  1. There are few areas where execution in Python is usually slower than that of Perl including regex and string-based operations.
  2. Sometimes it is difficult to get the type of variable in Python as in cases of very large code, you have to go till the end to get a type of variable that gets hectic and complex.

Perl PROS:

  1. Perl has powerful one-liners and even ensures UNIX piping like syntax which can be used on the 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.
  2. Perl is known for its powerful regex and string comparison operations as it is influenced by sed and awk like powerful UNIX tools. In the case of regex and string operations like substitution, matching, replacement, Perl outperforms python which would take a few lines of code to achieve the same. Also many file I/O operations, exception handling is done faster on Perl.
  3. When it comes to a language for report generation, Perl has always been in fame since its introduction as one of the main reasons for the author to develop language like Perl was for report generation.
  4. 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.
  5. It is easy to identify the type of variable with the symbols that Perl uses before them, like: ‘@’ identifies arrays and ‘%’ identifies hashes.

Perl CONS:

  1. Perl has a very complex code which makes it difficult to understand for a novice. Subroutines, and even other symbols like: ‘$`’, ‘$&’ etc are hard to understand and program for a less experienced programmer. Also, Perl code when read would be difficult and complex to understand unless you have a quality experience.
  2. OO Programming in Perl is a bit out of date as it has never been known for OO programming and many operations like threading are also less pronounced on Perl.


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, whereas 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.

So, in the end, it’s all upon the specific area you target. All your comments on this article are welcome and would request you to give your views on the topic if according to you Python wins or Perl.

Gunjit Khera
Currently a Computer Science student and a geek when it comes to Operating System and its concepts. Have 1+ years of experience in Linux and currently doing a research on its internals along with developing applications for Linux on python and C.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.


Leave a Reply
  1. I was put off by python’s exact indentation as a block requirement. I love the braces and they make for a clear block marking. It is hard for me to know which code block is aligned with which without exerting the extra effort of counting spaces (which is difficult to do if you don’t have characters immediately above and also don’t use fixed space font – another unnecessary requirement.)

    I want to use a font that is easier on the eyes and saves my eyes from the extra unnecessary effort of counting spaces.

    My codes are always clean with braces. I understand that it allows you to create messy blocks, but that is your problem, not the languages.

    I don’t like Perl either, I think its syntax is twisted. It seems like whoever wrote Perl gets schadenfreude making things difficult and twisted at the expense of making them readable and clear or a very bad communicator or both.

    How are you supposed to read print "hello0909there"=~/\d+/g

    print hellow0909there equal tilde slash digit slash g and understand it to mean print the string after removing the digits? WTF.

  2. The code examples in places leave off the ; at the end of Perl statements.

    Also, the Python examples don’t have proper indenting.

    Not impressed.

  3. Python:

        print re.findall('\d+','hello0909there')


        print "hello0909there"=~/\d+/g

    The first is plain to read and understand, and there is probably just one way to make it right.
    The second is harder to read and error-prone, requiring some knowledge of what’s going on.

    I find Perl more fun and interesting to write because it gives you so many ways to do things, each with its own subtle differences and implications. I feel more proud when I write a concise expression, where each character has been thought over than with writing code that tastes plain and foreseeable. On the other hand, I would prefer the latter if the code needed to be shared because I’d feel like I’d be pouring less of my personality into it.

    • Easier to read, really?! They both need you to learn regex in the first place.

      But even if it is easier to read you have to

      1. Import the regex lib and
      2. Those Python regexes are not even remotely as powerful as the Perl ones.

  4. Not only does Python have established and well-documented standards for writing beautiful Pythonic code, (PEP8), there are multiple utilities to help ensure your code is Pythonic. (flake8, isort, black, etc.) And anytime someone wants to contribute/publish to the huge number of libraries already in place, adherence to these standards is expected and insured before making it into those that ship with the language.

    Finally, Pythonistas love the beauty of good code standards so much that they even sing about it as can be seen in this YouTube video: https://youtu.be/hgI0p1zf31k


  5. “Beauty is in the eye of the beholder.” Unfortunately, some folks have gotten so used to the ugly they start to think it’s pretty when the reality is that it’s pretty bad, pretty ugly. As the song says, “The girls always get prettier at closing time.”

    Even though beauty is thought to be highly subjective, with mathematics good science is able to identify universally accepted beauty in the eyes of healthy humans who have not been corrupted and gotten used to the ugly. It comes down to simple ratios, for example, pleasant sounds follow the mathematics of harmonious music.

    Given this search for beauty, how does one scientifically identify beautiful code versus ugly code? It’s actually quite simple. Take a good sample of people from many backgrounds and disciplines who are highly literate but have absolutely no experience in programming. Why use this sampling? Because they come with no bias whatsoever. Show these folks representative examples of production code written in Perl and Python then: 1) ask them to read the code to understand what the program is doing; 2) ask them to evaluate readability and the eye appeal, AKA the beauty of the code. Conclusion? Perl is ugly.

    In our business, it is not so much what you know but how fast you can learn that counts. So if you are so enamored with your precious Perl that you don’t even want to try and master one of the most popular languages in the highest demand in the marketplace, then you are limiting your career options because of some kind of bias that you apparently cannot overcome.

    So is this writer biased? Well if following the science in the above studies that well demonstrate the conclusion, if rejecting the realities and overwhelming consensus of the marketplace and wisdom of the masses is biased, then okay.

  6. Having written Perl for more than 20 years, I find the argument over readability lies more on the developer and becomes a crutch of an excuse for one language over another. I’ve been indenting my code, much the way Python forces you to, for the better part of my career, because that argument of ‘hard to read’ is true if the developer doesn’t follow some level of sane formatting and code style standards.

    Yes, I’m old, and the whole “teaching old dogs new tricks”, but my biggest issue with Python is it’s ugly. Perl, PHP, Java, Javascript, Go, etc.. all of the C-derived languages are very similar in syntax and code layout standards. Python is a complete 180 from all of these languages, coupled with its long-form requirements for the same thing Perl can do in a fraction of code, makes it quite difficult for someone who is C-based to jump into Python and get much done in the same amount of time that you can in Perl.

    I don’t even want o get on the versioning incompatibilities that Python brings with it. Every Python developer I know had a great rant-fest when Python3 came out requiring them to refactor all of their previous code. I’m working on a project now, with my Linux distro of choice (Debian) caping my Python version at 3.5, yet other developers (using Mac) are running 3.8. There’s enough of a syntactical difference in that minor version that their code won’t run on my system, so much for collaborative coding.

    • The current version on the current Debian is 3.7.3.

      If you want to have compatible programs with previous versions, you need *not* use new functionalities.

      There is a lot of programming languages with syntax different than the C-base syntax. I currently develop in Ada. There are others completely different like ML, Haskell, etc.

  7. What I’m reading is that if you already know Perl, there is no real reason to learn Python. (Apart from when you need to collaborate with people that are too lazy to learn the syntax of a more powerful language. ;-P )

    I don’t mind a language that is made for maximum readability, but the nerd in me does love a language where it makes sense to have Obfuscated Code Contests :-D and that you can really utilize for powerful one-liners on the command line when you need to parse something.

    Another (personal) note on the readability, is that I really do NOT like that indentation is part of the syntax, it makes it easy to miss the end of a block. I firmly hold the opinion that white spaces should NOT be part of the syntax. To me, it makes it much less clear to read code that relies on indentation only to mark blocks compared to (well indented) code using braces (curly brackets) which clearly mark the beginning and end of each block.

    Even though I’m still to see some Python code that couldn’t be written more efficiently in Perl, Python has gained its place in the DevOps world with its more true OO approach. Python is here to stay, BUT i.m.h.o. it will never push Perl out of the hot seat of being the most powerful and useful scripting language.

    • # Is python easier to read? Generally yes, but even the simplest things sometimes use
      # many lines of code and things might get complicated / hard to read especially 
      # if the code should run in both python3 and python2
      import os
      import platform
       if os.name == 'posix':
        table= int(input("Which multiplication table to print? "))
      for i in range(1,13):
       if(int(platform.python_version()[0]) < 3):
      # Whereas Perl might not always be easy to read for the novice,  but is powerful and 
      # allows for compact code that's still easy to read with it's clear blocks:
      do {
          print "3[2J3[0;0HWhich multiplication table to print? ";
      } until $table =~ m/^[0-9]+$/;
      for $i (1..12) {
          print "$table x $i = ", $table*$i, "\n"
  8. Python is a fast development language that is widely used. Program execution is only slow for those who haven’t yet learned how to properly use it. The rapid rise in popularity and wide usage of Python confirms that is a great language for programmers to master.

    It is the “go-to” language for successful companies like Google and Fakebook. Then there’s the abysmal failure of Perl 6, continually decreasing Perl jobs and the ever-steady slow decline of Perl popularity and usage.

    The wisdom of the overwhelming majority has already spoken. In the many lists of best programming languages to master Python is always near the top or at the top while Perl is nowhere to be found. This debate has already been settled in the marketplace. Why be an expert in a dying language? Career-wise, It would be better to be an expert in COBOL than Perl.

    There is value to knowing some Perl, but the choice for the future is clear: You can get on board with a modern language (Rust, Go, Python, Closure…) or you can let your career prospects dwindle with Perl, a relic from the past.

    • That’s quite an interesting analysis, but is it factual at all? Perl was already “dead” before I spent about 20 years worth of my career developing on it, which sorry, defies your argument pretty much from the get-go.

      Adoption means nothing, as programming languages can become widespread for any number of reasons (think Visual Basic and later the whole .Net platform if you need any examples of crappy languages still totally widespread).

      Besides, the biggest and best out there still make extensive use of Perl: Apple, Microsoft, Amazon (and quite extensively so), eBay, JP Morgan, Dell, and so many others, not to mention the fact that while PHP is a terrible language in many regards it still outranks Python hands down on usage metrics.

      Among other things, Perl 6 (later renamed Raku in its former Pugs implementation) didn’t exactly “fail” per se: it broke backward compatibility, which has always been considered crucially important among Perl developers who need to keep running code occasionally decades old, and so it became the prerogative of bored Haskell experts (seen as that’s the language Pugs was built on).

      On the other hand, the need to be able to use multiple tools is hopefully self-evident and in no way detracts from the inherent value of Perl. When it comes to speed, I hear everybody say Python is the winner, yet XS makes it quite easy to introduce C code where speed is a concern – which can be also done in Python, but is massively more difficult and undermines the whole “easy to learn/use” argument we all agree is one of the main advantages of Python.

      Lastly, if you need language constraints in order to get readable code, you need better engineers, not a better or more constrained language. Language constraints were meant to make Java code more readable, and look at what a hot mess it is now – not like I’d to assume anyone who’d rather learn COBOL than Perl on prejudice to understand what I’m on about.

      So, in conclusion, I most categorically disagree with your Mickey Mouse analysis. Personally, I will keep using whatever language seems appropriate for the task, including Perl (regardless of what swathes of laymen have been considering “dead” now over decades, much to my hilarity), and keep earning six figures for it. Thanks at any rate for the opportunity to dismantle your papier-mache’ argument, here’s hoping there’s more where that came from.

  9. Python is a weakly typed language! Python interpreter is parsing every line multiple times to determine the type of variables and does a lot of type conversions which makes Python super slow. Stable type programming in Python is flat out not possible. In Perl, you can use it strictly to make it strongly typed language. OO in Python is a joke from a CS point of view. Perl is not an OO language regardless of marketing gimmicks.

  10. I think Python has its place as a learning language and as a wrapper language for third-party-libraries, which will do the real work for it to shine.

  11. I disagree!!!

    Python is very difficult to read, but Perl is really easy.

    Also, I disagree, that curly brackets are ugly.

  12. It seems to me that each mention of requirement of third-party libraries for Python is misleading because this functionality is available with the *standard* library.

  13. Hi Gunjit,

    Thanks for writing this article. Lately, I needed also to work with python, and I was wondering if there is really a killer feature in that language, which would explain why it is so popular. Until now I still didn’t find it. But the simpleness of Perl for processing files, especially with its built-in RegEx support is still superior. Then what always comes is this indentation nonsense.

    Python fanboys always claim that python code would be cleaner. What they try to sell as an advantage is the biggest disadvantage of python.

    1. As David G. already pointed out writing clean maintainable code has to do more with the programmer, than with the language. Nothing to add here.
    2. Giving whitespaces a syntactic meaning is complete “brainfuck“. Only esoteric languages like “whitespace” do this… and python.

    In most languages where you have braces (C, C++, JAVA, C#, Perl, …) or equivalents (e.g. begin … end) the code can be auto-formatted.

    • you can reformat the code at any time using smart editors or external tools.
    • editors normally will auto-indent to the correct location while typing. E.g. you type "if (...) {" it will jump automatically to the correct indentation. You write more code then type "}" end it will jump again to the high scope automatically.

    You lose most of these advantages because the editor does not know to what scope your commands belong without braces.

    The whole point of “python is cleaner“, because your code does not work anymore correctly without correct indentation is nonsense. The problem they tried to fix, is more or less non-existent due to smart editors and auto-formatting. Or do you code in notepad?

    Ugly code suffers from bad naming of variables, functions, missing comments, bad software architecture, not because of the wrong indentation. If it is indented wrong you can easily fix it. E.g. in Vim by selecting the code fragment or whole file and pressing "=". Done.

    I just needed to say that ;-)

    Back to Perl vs. Python. Both languages support the same features sets, more or less conveniently. While Perl has some cool built-in language features like RegEx, Diamond-Operator, Backquotes for executing commands (like in BASH), etc., in Python most of this is solved through external libraries.

    Working with arrays, tuples, or structured data work in both languages. Python supports OO programming, whereas in Perl this is more an extension that was not there from the beginning.

    When it comes to libraries both worlds offer almost everything (often through the same underlying C libraries). Perl and CPAN are very old, very stable, but today many packages are not maintained anymore. But often they still work, why not?

    In Python, I often had compatibility issues, because library designers cannot keep the API stable. This really sucks if you need to update the system, and applications are broken. In Python people now use virtualenv to work around these issues. But still, this is a workaround that should not be necessary. (Maybe programmers who cannot format code correctly should not write libraries…:-)

    Then there is this python 2 vs python 3 incompatibility. What the f**k. Never have seen such a major break in any other language.

    So why is Python so popular? IMO it is not the language itself. Major drivers are killer applications. Like Rails was for Ruby. In Python, I know two major killer applications. Numpy and Jupyter Notebook for scientific computation.

    In Perl, there would be PDL for this purpose, but it is much less known.

    Today you read so much about python, not much about Perl anymore. So it is clear to me that young people will learn python, not Perl anymore, even though technically I still don’t see that big advantage.

  14. Great article – thanks.

    One point about the language. When you say “Python’s code is lot more cleaner” it sounds a little clumsy. It could read better as “Python’s code is lot cleaner”


  15. Are you really a python programmer? In Perl you can create clean or ugly code, it is up to you. I mean, forget the “ugly” programming capacity of Perl and you will have a “python like” language. It is named freedom ;-)

  16. I think Perl’s OO support with Moose remains unsaid here. Moose is good enough that other programming languages have started copying it.

  17. Code cleanness and readability can not be seen as a feature of the language. It is rather limited to the programmer’s way of writing and experience to make code maintainable and readable. Perl’s syntax which is also common in other languages, makes it even familiar and understandable. The flexibility that Perl offers to write code in different ways is more of a strength than a weakness.

    • Exactly!

      Too bad, there is no way to put the thumb down on this brainwashing article.

      Pythoners hying Perl is like Americans hying Rusia.

  18. The example which is supposed to show the brevity of Perl over Python is bad: it just translates Python to Perl.

    The way to accomplish the task of printing every line in data.csv is the following:

    # perl -wnp -e '' data.csv

    That is to say, it takes 0 lines of Perl to do that vs. 6 lines of Python.

    And I say this as someone who doesn’t know Perl; I’m currently learning it from Tim Maher’s excellent Minimal Perl book, because I got tired of writing bash scripts with grep, awk, and sed – and writing a Python program for simple text processing tasks is often too verbose.

    From what I gathered, Perl is what one would be better off using instead of the aforementioned bash/grep/awk/sed combo: it was built for that purpose, and supports the syntax.

    On the other hand, I’ve used Python to write things like convex hull algorithm in 3D and scientific computing within the SAGE ecosystem; it was much more pleasant to do these things in Python than, say, Java or C++ (and clearly, it would be insane to do this in Perl).

  19. The biggest aid/hindrance to readability is, always has been, and always will be, source code commenting. I find that gobbledegook code can be written just as easily in Python as in Perl, or any other language come to that (including Cobol).

    There’s no substitute for extensive in-line comments. Comment your code and you can pick it up years later and immediately see what it’s doing. That’s true whether it’s written in Python, Perl, C#, Assembler, whatever.

    Python vs. Perl – not a fair contest, they should be used for different things.

    The biggest issue I’ve seen with Python is the evangelists who think it’s the best thing since sliced bread, and that they can do anything with it. Only last week I came across a system written in Python which runs a database driven dynamic website.

    It had to call in so many outside libraries and packages that it’s a total mess. Understood only by the guy who wrote it 5 years ago, and he has long since moved on. Basically it replaces Apache and PHP but goodness knows why (it’s running on a LAMP server!). Probably the guy thought it was a challenge to write it in totally the wrong language.

    I bet he was chuffed when he finished it – probably took him 3 months to write something which I could’ve done in PHP in 3 days. Use the right tool for the job. Python or Perl? Design the system first THEN choose the tool.

    OO programming in Python? No – wrong tool! Use a language where OO is innate, not one where it’s been tacked on as an afterthought.

    (p.s. comparing say Django or Web2Py with Perl is unfair – a derivative is not the same as raw Python)

  20. Some of these perl examples don’t really reflect what’s more-or-less standard in the Perl community at any time since Perl 5 came out (15 years ago).

    Keeping in mind the vision of TMTOWTDI, your second Perl example:

    open(FILE,”%lt;inp.txt”) or die “Can’t open file”;
    while() {
    print “$_”; }

    …really would be typically written as just:

    open (FILE, ”inp.txt”) or die “Can’t open file: $!”;
    print while ();

    As many others have pointed out, Perl has a huge amount of syntax flexibility despite its overtones of C heritage, and that allows people to write working code in a relatively ugly, inefficient, and/or hard-to-read manner, with syntax reflecting their experience with other languages.

    It’s not really a drawback that Perl is so expressive, but it does mean that the programmer should be as disciplined as the task warrants when writing it when it comes to understandable Perl idioms.

    • Thanks for Updating us with your knowledge and we would surely correct our code with the updated one as given by you.
      Stay Connected :-)

  21. 1) I’ve usually found that the clarity and elegance of a program have a lot more to do with the programmer than the programming language. People who develop clean solutions will do so regardless of the language of implementation. Likewise, those who can’t program will find a way to force an ugly solution out of any language.

    2) Most systems administrators aren’t programmers and have rarely had any formal training in software development.

    Put these two observations together and you will still get ugly, “write only” programs Before perl it was shell script, yesterday it was perl, today it’s Python. Tomorrow someone will be asking for a replacement for Python because it’s so hard to read and can’t be maintained. Get used to it (but don’t blame the programming language).

    I started my perl programming with perl 2.0 in 1993. It’s still my “go to” programming language since it doesn’t get in my way and I can get to a solution much faster than with C or shell script.

    • You pointed out, that those who are programmers would find out clean and understandable solutions out of any language, while non-programmers would stay on getting ugly solutions out of any language. Its really on the experience of person and his familiarity with any language.
      Thanks for sharing your views with us. Stay Connected :-)

  22. The major breaking point for Python, why I can’t recommend it to anyone: UTF-8. It’s a lot to get into, but long story short: Unicode in Perl is tricky, in Python it’s fundamentally broken.

    Unless you’re only ever going to be working with people who speak ‘murrican, don’t use Python.

    Also: Perl 6 for the win.

    • Unicode in Python 2 was slightly tricky, Unicode in Python 3 is a breeze. I don’t understand why anyone would think otherwise.

  23. This article is a pretty good summary of the differences and advantages of each. I agree with the conclusion, both have their strengths, use the right tool for the job at hand. This is true no matter which languages you are considering.

  24. Gunjit, you made no mention of modern OO Perl development techniques. Nobody codes what we call “classic” Perl modules anymore.

    • Yes, you mentioned it right, perl 5 introduced OO Programming.
      Thanks for updating us and sharing your knowledge with us and other readers.
      Stay Connected :-)

  25. This article leaves out very important design flaws in the Perl language, which can very easily lead to absurd security vulnerabilities, if you’re not 100% careful all the time.

    Look at this presentation:

    Furthermore listing small performance gains (which I didn’t benchmark; did you?) between two SCRIPTING languages is totally pointless. It is like comparing two dish washers regarding their ability to knit a scarf. If you need performance for something, code (at least that critical part) in a compiled language like C or Rust.

    • Yes, but certain use cases favor the use of perl and there these minor performance gains matter, like regular expressions matching. Although i agree that as a scripting language, if you need performance you have lots of other options like: C and Rust as you pointed out or some other like: Go which can enhance concurrency when we talk of programming web servers , but Perl’s major advantage is its closeness to Linux and its tools i.e. awk and sed and its one liners where it can give a better performance.

    • Actually performance does matter even for scripting. Imaginew filtering a 100 MB debug log. You could use AWK or gawk, sed or grep but Perl gives a lot more flexibility. Taking 5 seconds is very different to taking ten seconds, just because the more time between request and response the more likely you are to get distracted.

  26. perl is absolutely the finest – most wonderful of all options – and it makes programming languages “great again”. Everybody but python programmers know that ;-)

  27. I would pick Python most every time over Perl if given a choice. Why? Readability and ‘ease of use’ trumps everything else… KISS principle at work… A few more lines to do the same job is worth it if you can ‘read it’ at a glance. For what we do, Python 3 does all we need for tasks we require of it whether reporting by writing Excel spreadsheets, or CSV, or XML or…., or networking, or simpile GUI with QT4 or Tk. In fact one of the things I was tasked at my company to do is replace the Perl scripts that were written before hand with Python replacements, so that the next guy (whether a programmer like me, or an Electrical Engineer) that comes along can easily understand what is going on if changes need to be made. The little speed you might get from Perl is inconsequential for what we are doing (pick right tool for the job of course). As for ‘ regex’, Python comes with the module ‘re’ (import re) if you need that capability. I don’t feel we have lost anything by dropping Perl and gained everything by embracing Python IMHO.

    • Thanks for sharing your views, these would be very helpful for our readers also who might be confused on choosing one of the two languages.
      Also Thanks for being a follower of tecmint, Stay Connected :-)

  28. Perl is almost dead in the modern sysadmin/devops arena. Ruby is the new Perl. An article on Ruby vs Python will possibly get more hits.

    • WRONG!!!

      How can the most powerful, beautiful, and easy scripting language, as Perl be dying?

      Python is awkward. How can anybody in their mind like it?

      I only use it out of necessity, when I need to write macros in programs, that have python built-in. I would rather prefer Perl because it’s more pleasant. In fact, if there was the choice, where Perl is not an option, I would rather choose c++ over python!

  29. Your regex example is biased.

    Consider Python:
    print re.findall(‘\d+’,str)

    Versus Perl:
    print “$& \n”

    If you look at it from the perspective of the uninitiated, it’s very obvious which one is easier to understand!! “$& \n” is UGLY!

    • Although $& seems ugly but with course of time a perl programmer can get practice of such syntax, although same would be with the python one, but main thing here would be that perl is more powerful in regex as it is inspired by and also inspired to run on linux OS, which makes it have an upper hand on python for pattern matching.

      • Yes, but I asked you to look at it from the perspective of the uninitiated. While regex is a powerful tool, there’s WAY more involved with systems engineering than mere string manipulation. There are several Python web server development tools which use high performance regex for routing as a core function. Properly written Python regex routines can perform very well. If your usage of Python regex threatens the viability of your app then I’d say you have a design issue. IMHO.

  30. The Pythonic file handling below surpasses the Perl example, the exception text and file close is automatic. Advantage Python!

    with open(“data.csv”) as f:
    for line in f:
    print line,

    • Yes, Thanks for sharing another important point i.e. file handling , this would surely advantage our readers.
      Stay Connected :-)

      • Well it’s not really file handling, it’s understanding and using context managers. You were presenting a conclusion based on sub-optimal Python code! I will “stay connected” if you grant my point that in this specific example of yours it’s advantage Python.

    • In Perl, you don’t have to close the file, because it’s automatic, if the program as simple, as Python example above.

  31. I have read this article entirely and now I could say python will be best over a Perl ,it may third party but doesn’t matter and the matter is able to support most of the technology .

    • Thanks for sharing your view about the debate. It would surely be helpful
      Thanks for being a follower of tecmint, Stay Connected :-)

    • Nothing about the re module is third party. It is part of python. You have to explicitly import it just to avoid name collisions. It allows you to have a variable name that is "re" in code which doesn’t use regular expressions at all.

    • Ha IMF experience in both, I prefer Perl in everything, including pleasantness and briefness of writing and maintaining.


Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.