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

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.45/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

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.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

35 Responses

  1. Moises Burset says:

    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 ;-)

  2. Aniket Inge says:

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

  3. Kefle says:

    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.

  4. Roman says:

    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).

  5. James says:

    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)

  6. Dominix says:

    Python centric bullshit

  7. J Cleaver says:

    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.

    • Gunjit Khera says:

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

  8. David G. Miller says:

    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.

    • Gunjit Khera says:

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

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.