Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Argument for Perl ( again and again )

by heatblazer (Scribe)
on Oct 16, 2012 at 08:10 UTC ( #999252=perlquestion: print w/replies, xml ) Need Help??
heatblazer has asked for the wisdom of the Perl Monks concerning the following question:

Hello, monks

I know it`s been asked tons of times if Perl is this if Perl is that. A friend of mine was trying to make me believe that Perl is no longer popular, since the fuzz is around Java with android, Python and google, javascript and DOM API. I saw some of his refs, in which really the chart showed that Perl was at it`s top in 2000 year and now it is going down and down. So he asked me: "Why Perl?" and these are my reasons:

  1. Perl is fast ( which is the easiest thing to say
  2. Perl comes with a huge library 3rd party files - the CPAN
  3. Perl has many build in unix-like commands like chdir, link, unlink, chmod, etc.
  4. Textual files are processed like a child`s play
  5. Perl is easier to understand than Ruby or Python, even though it`s syntax is a bit different

Well, my arguments were the things I found useful and the things I like in Perl, not that there might be the same in other langyages, I know not of. He replied with:

  1. Perl is hardly OOP, not an easy like Java, Py/Rb or PHP

  2. Python is widely used nowadays from Google, PHP is the main language for the WEB, and Javascirpt is the language of the browser. JAVA is a general purpose language, strictly typed with x-compatibility. LUA and javascript are better glue languages.
  3. Regex is not bind to Perl, every language has a regex functionality. A regex excellence is not a good argument.

So, I step aside, since arguing for languages instead for approach is ridiculous. There is a programming approach, not a programming language. You chooshe the best for you. But, I am asking the expert monks here, the ones with knowledge in many languages to give me some arguments - why Perl. Not the trivial explanations that Amazon uses it, and it`s been around 30 years... It`s a technical reference, the way it surpass other languages. Why it beats python, what Perl has that others don`t and why Perl is worthy to learn, beside a SH successor.

Replies are listed 'Best First'.
Re: Argument for Perl ( again and again )
by blue_cowdawg (Monsignor) on Oct 16, 2012 at 12:30 UTC

    Gee... I've been in the IT field long enough that I remember hearing "C is dead".. "C++ is dead" "COBOL is dead", "BASIC is dead" and on it goes.

    It wouild seem to me that C and C++ are just as alive today as they were in the late 1980s when there were those that thought they were dead. In fact the company I work for has been using C++ for our core products to this day.

    BASIC hasn't gone away either. It may have morphed into other things such as the dialect of BASIC used with the Stamp and Stamp II micro-controllers.

    Perl is not going away soon in my humble opinion. As evidence I offer up the last contract job I took on with a major financial institution who had such an investment in locally developed Perl modules it would take them at least 20 years in my thinking to replace all that functionality.

    As for JAVA. I program in Java and I find myself frustrated with the language on numerous occasions finding it rather difficult to do things in the language using 20 lines of code where I could do the same darn thing in 5 lines of Perl. As a web language under such web containers such as Tomcat, JBoss, Weblogic and others you are constantly dealing with memory issues.

    PHP is another of those languages that I try and avoid writing code in it. Seems to me it takes a lot to get simple stuff done.

    Ruby is a relatively new language to me and the jury is still out. I get interested in Ruby because of my interest in Puppet which is a system configuration management tool. Puppet is written in Ruby and can be extended with new types and providers by writing Ruby code. Ruby on one hand reminds me of Perl in some respects and is cryptic as all get out on the other.

    Python... I don't do snakes.

    Getting back to Perl. I spent some time as an adjunct professor teaching Perl to the masses. The majority of my students were Visual Basic (another form of BASIC!) or Java programmers. Once I got them over the fact that they'd actually have to use some sort of text editor to write code instead of a neat GUI or IDE with on the fly syntax checking I was surprised to see how quickly I could take a class of students from

    #!/usr/bin/perl -w use strict; my $w1 = "Hello"; my $w2 = "World"; printf "%s %s!!\n",$w1,$w2; exit(0);
    to writing their own modules and producing decent code.

    I guess one of the "take aways" here is that the actual language you program in doesn't really matter. It is the mindset of the programmer doing the work, their ability to organize the steps of the solution to a problem, and when things go bad their ability to debug/troubleshoot the code.

    I've seen (and been responsible for) some really ugly code in a wide range of languages from my beginnings in 1972 with Dartmouth BASIC and Fortran IV, to COBOL in 1974 and up to the present day with C/C++/Java/JavaScript and of course my favorite language, Perl. I've also seen very elegant code (including some of my own) written in the same languages.

    Another "take away" I can offer as well I have a workshop at home with tools ranging from simple screw drivers to a small lathe. I have electronic instruments ranging from VOMs to Oscilloscopes. If I need to hang a picture on my living room wall I am not going to drag the lathe up from the basement to bang the nail in. As absurd as that sounds that is what some folks try and do in the programming world. Anymonk remember the TCL/TK web browser plugin? </p.

    If I need to do AJAX on a webpage I need to use JavaScript. As far as I can tell there is no way around that if I want to be browser neutral. Having brought up browsers I can tell you that writing JavaScript that runs on every possible web browser out there can be a challenge at times. Try using the DOJO framework and see what happens when you compare the results between Firefox and IE5. Not pretty.

    The backend to AJAX doesn't matter. I can write that in Java withing a web container, I can write that as a RESTfull service in Perl. I can even write a web service in Ruby on Rails to get the job done. What is going to drive my decision as to which I'm going to use is going to depend on the application itself, the environment it is running in and what is already running on the target web server. If there's no CGI support on the web server but they are running a web container, guess what? I'm going to end up writing the back end in Java.

    No one language has all the answers.

    I will now fall off my soapbox.

    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
      Actually, there's ActiveState (payware) and Padre (free) if people really want a Perl IDE with syntax checking, refactoring etc.

      Other than that, I whole-heartedly agree with everything you wrote.

      -- Time flies when you don't know what you're doing

        I also use Eclipse with the EPIC plugin. The debugging features in Padre are not there yet (hopefully at some point they will be), but are definitely better in Eclipse-EPIC. Eclipse-EPIC is a but a bit clunky however (as many JAVA projects are).

      "If I need to do AJAX on a webpage I need to use JavaScript. As far as I can tell there is no way around that if I want to be browser neutral."

      You could always write client-side scripts in a subset of Perl.

      perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
            You could always write client-side scripts in a subset of Perl.

        Write in Perl and translate to JavaScript? Pretty much amounts to the same thing. As far as I remember you can't run Perl in a browser unless they snuck that into the more recent HTML standards... :-)

        Peter L. Berghold -- Unix Professional
        Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
Re: Argument for Perl ( again and again )
by tobyink (Abbot) on Oct 16, 2012 at 12:05 UTC

    Perl is not an OO language; it's a multi-paradigm language giving you the flexibility to mix OO code with other styles of programming.

    Whatsmore, Perl's OO system allows you far more power and flexibility for OO code than Java or Java-inspired OO systems (PHP's is Java-inspired). And projects like Moose allow you to take advantage of that power without tearing your hair out!

    Java's version of OO is very limited. It's single-inheritance, class-based OO. Many Java developers seem to believe that's the only true form of OO. Some will acknowledge that multiple inheritance is occasionally useful, but that it can also introduce problems (e.g. diamond inheritance). Few are aware that other entirely non-class-based forms of OO are also possible, such as aspect-oriented, role-oriented and prototype-based OO.

    Here's an example in Perl (with Moose) using both classes and roles to take a plain old instance of the Person class and install a new method for that object only (not the entire Person class).

    use v5.14; package Person 1.0 { use Moose; has name => (is => 'ro'); }; my $alice = Person->new(name => 'Alice'); my $bob = Person->new(name => 'Bob'); # Teach Bob to sing! Moose::Util::ensure_all_roles( $bob, Moose::Meta::Role->create_anon_role( methods => { sing => sub { say "lalala" } }, ) ); foreach my $person ($alice, $bob) { say $person->name, " can you please sing?"; if ($person->can('sing')) { $person->sing; } else { say $person->name, " cannot sing!"; } }

    So even if Perl isn't an "OO language", it provides an arguably better and more complete OO programming environment than Java.

    Also, while other languages may "have" regular expressions, these are generally just "match" and "replace" type functions which can be passed a regular expression and a string. In Perl, they're an integral part of the language...

    use v5.10; my $count = 0; my $var = "foo <> foo <> foo"; $var =~ s ( fo{2} ) { ++$count; }gex; say $var;

    Whatsmore, regular expressions in Perl are far more powerful. (More powerful even than those languages that provide the "Perl-compatible" regexp engine - this regexp library was compatible with a very old version of Perl; Perl's improved since then.)

    Lastly, I'd say you undervalued CPAN. It's not just a repository of libraries; there's the whole infrastructure that goes with it:

    • CPAN Testers which provides a testing service for everything on CPAN on a variety of different platforms. They'll even test your code for free if you open-source it and upload it to CPAN.

    • The CPAN admins, whose existence ensures that should a module ever be orphaned by its developer, if there's a willing volunteer to take it over, they'll be given permission to do so.

    • The various CPAN websites (e.g. which make all the documentation on CPAN browsable and searchable, and link to reviews, issue trackers, etc.

    • The various CPAN installation tools that handle dependency resolution in a manner that rivals apt-get, etc.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: Argument for Perl ( again and again )
by sundialsvc4 (Abbot) on Oct 16, 2012 at 13:34 UTC

    Argument?   What argument?   Everybody who’s anybody knows what the only right answer is, such that anyone else (who disagrees with moi!!) is just a ... ;-)

    Ahem ...

    Personally, I like ’em all, and use ’em.   (Although I am very nervous about the way that Python assigns semantic meaning to indentation ... but it’s a cool language.)   The simple reality is that you’re going to walk into some new “shop,” either on a gig or as an employee, and they are going to have built their production system around one-or-more language(s), such that you are going to be obliged to quickly come up to speed in whatever-it-is ... and, being a pro, you will.

    You have to be apolitical about these things.   They’re all tools for the job, nothing more or less.   Whether the particular selection that was made, and/or the approach that was begun, was or was not “in hindsight, the best choice we could have made,” it was nevertheless the choice that was made, and now the $$ value $$ of $$ that working source-code is immense.

    To me, the Perl (5...) language itself is more-or-less par, with a few interesting features.   It has a massive CPAN library at your beck-and-call, and, as you have said, it makes the processing of text-files easy.   And, yes, it is quite fast.   (I don’t particularly lend credence to “is easier to understand,” because that’s just a matter of familiarity.   I switch between languages all day every day anyhow.)

    Like everyone else, I have a job to do, and I want to get that job done as quickly and efficiently as I can manage.   When I can grab a handful of known-good CPAN modules, stitch them together with some code and come up with a solution that has sticking-power, like anyone else I’m going to trend toward the most well-worn tools in my box.   All of these various language designers really know their stuff, and they’ve given us a tremendous choice.   The very best of the best of the best of the best, of course, being ...   ;-)

Re: Argument for Perl ( again and again )
by 2teez (Vicar) on Oct 16, 2012 at 09:58 UTC
Re: Argument for Perl ( again and again )
by Anonymous Monk on Oct 16, 2012 at 11:38 UTC

    Actually if your friend is really so much for 'fuzz', then he must know by now Python and Java these days get regularly trolled on many programming forums. People are just fed up with technical bureaucracy associated with Java, XML/Configuration mess, dependency management, endless pool of mediocre programmers which generally makes it difficult to identify good programmers.

    Coming to Python, yes it was famous around in Google. But from the news that is coming out now, they have deprecated it in production especially for API usage, due to lack of strong type support. Its a very good language by the way, but breaking backwards compatibility with Python 3 just for things like print statement has made many users still stuck with Python 2.x series. The Python 3 adoption is and has always been very slow even after so many years after its release. Scoping is bad broken, there are some good frameworks. But given how brittle their syntax is, they are likely to break backwards compatibility every time they make a non trivial change to their syntax/semantics.

    Javascript is hip because of NodeJS, but trust me languages like Go are likely to Python's lunch big time. And Rails eat Php's lunch long time back.

    So if your friend is too much for 'fuzz', he must look at scala, clojure, coffeescript, NodeJS and those technologies alike. Python, Java, Php today are likely to be trolled and considered as much equally ancient as Perl.

Re: Argument for Perl ( again and again )
by Jenda (Abbot) on Oct 17, 2012 at 08:27 UTC

    1. Perl is as OOP as you want it to be. You can turn even the builtin types to objects ... though I see no reason to want to. Including PHP in the list is simply ridiculous.

    Python? I don't know ... the only time I ended up finding any Python at all was e-book format conversions and Kindle format tweaks. PHP is the language of script kiddies. Agreed on JavaScript. Java is a marketing campaign not a viable language. If you want to hire a hundred off-shore monkeys to emit lots of LOC, then an overly talkative and insanely inefficient language like Java is probably a plus, but what if you want to get things done?

    3. The presence of some kind of regex doesn't really mean much. Say C# does have a Regex class with a plethora of Match, Matches, MatchGroup, MatchWhateverTheyCouldComeUpWith classes, but the interface is simply so awkward and inconvenient that even I resort to regexps only if there is no other way. Not because the regexp would be so complicated, but rather because you've got to jump through too many hoops before you are allowed to write one. I seriously doubt Java is better in this regard, I'd expect it to be even worse.

    It's like the difference between having a knife and being able to send the bread with a stamped, filled in request form to have it cut and sent back. There's a knife involved in the process somewhere, the difference is in its accessibility.

    Enoch was right!
    Enjoy the last years of Rome.

      Including PHP in the list is simpli ridiculous.

      Why? Its object oriented

        Because objects/classes had been an afterthought in PHP just like they were in Perl. PHP added some syntactic sugar out-of-the-box and at the same time restricted the object system quite a bit more than the Perl's "we provide the hooks, polish and use them as you wish" way, but neither was designed to please the OO purists.

        Enoch was right!
        Enjoy the last years of Rome.

Re: Argument for Perl ( again and again )
by davido (Archbishop) on Oct 17, 2012 at 18:34 UTC

    Don't try to convince someone by trotting out a list of things you think make Perl cooler than other languages. Chances are good that the person who knows "other language" better than you will already know how to accomplish the same thing in a more "other-language-ish" way. Any Turing-complete language can find a way to achieve the same goal. Sure, more work goes into writing an HTML parser in C, but the C folks have undoubtedly accomplished it at some point along the way, and they may have actually invented something the rest of us could learn from.

    ...which brings me to the main point of my post: Other languages aren't the enemy. They're neighbors. They're influencers. They're co-innovators. Perl was born out of a desire to take some of the best ideas of other languages and combine them in a way that turned out even better. As soon as we dismiss another language as being a fool's errand we're no better than those who scoff at Perl, dismissing it because of some misguided, under-informed reasoning, and in so doing, missing out on some really cool things.

    Perl moves forward when people bring fresh new ideas to it. Moose wasn't invented in the vacuum of a Perl-only world. It took some of the better features from other languages, invented a few of its own, and combined them all in a way that gives us one of the better object systems available to a multi-paradigm language. Regular expressions weren't a Perl invention. But PCRE has become the de-facto standard because Perl took some of the best Regex features, added some more cool ideas, stole a few cool ideas from other languages later on, and developed one of the richest, most powerful (and most difficult to master) regex syntaxes available. Perl's generic containers weren't a Perl-only phenomenon, even back in the 80's when Perl was invented. And more recently, Plack is an idea lifted directly from another language, and made our own.

    What does this have to do with defending Perl? Well, if there's a point I'm trying to make, it's "Don't!". Instead, ask the individual if there's anything in Perl he thinks might provide inspiration for the betterment of his favorite language. Play to his interest in his own language. But above all, listen to what he has to say. We all benefit from an open dialogue, free from defensiveness.

    As an example, C++ might actually be a better language if someone could just figure out how to give it anonymous subroutines and closures. C++11 did just that, and there are lessons we can learn from the C++11 implementation back here in the Perl world. This open dialogue thing is a two-way superhighway (or it should be).

    If you want Perl to continue to move forward, don't defend it. Innovate. And encourage others outside of the Perl world to innovate as well. Furthermore, encourage others inside and outside of the Perl world to explore each others' languages, and bring the best things they find back to their own language. As we watch that evolution we'll learn some new tricks too.


      Don't try to convince someone by trotting out a list of things you think make Perl cooler than other languages. Chances are good that the person who knows "other language" better than you will already know how to accomplish the same thing in a more "other-language-ish" way.

      That's a good point. And if he really cared about regexes and glue language, he'd already be using Perl. The fact that he thinks one regex implementation is as good as another tells me that a list of Perl's strengths just isn't going to impress him. (The fact that he used "easy" and "Java" in the same sentence makes me think I wouldn't try.) Perl isn't a buzzword language; a lot of what makes it special is hard to define.

      Take statement modifiers, for instance. At first glance, they may seem superfluous -- they don't let you do anything you couldn't already do with normal loops. But it's hard to describe how much they aid the process of reading and writing code (and how frustrating it is to switch to a language that doesn't have them). Similarly, it's hard to explain why =~s///g is so much better than preg_replace(), but it is. I think a lot of Perl is that way.

      Aaron B.
      Available for small or large Perl jobs; see my home node.

        I think the most successful tack is the one that encourages someone to investigate, not because "mine is better", but because "different is enlightening." Here's a quote I happen to like:

        Thoughtlessly applying techniques effective in one language to another typically leads to awkward, poorly performing, and hard-to-maintain code. Such code is also most frustrating to write because every line of code and every compiler error message reminds the programmer that the language used differs from “the old language.” ...Every language can be a fertile source of ideas... However, ideas must be transformed into something that fits well with the general structure of [the new language] in order to be effective in the different context.

        – Bjarne Stroustrup The C++ Programming Language, Special Edition.

        (Emphasis added.)

        My feeling is that most of the time when people are quick to dismiss another language it's because they haven't learned enough from it to get past the stage of "thoughtlessly applying techniques effective in one language to another", and are frustrated because "every line of code and every compliler error message reminds the programmer that the language used differs...". Given a chance, most languages have at least something to offer. I think Perl has a lot to offer to those who are willing to work past the awkward stage.


Re: Argument for Perl ( again and again )
by Anonymous Monk on Oct 17, 2012 at 14:47 UTC

    I find myself going to Perl a lot lately. I have to write some sysadmin scripts that must run on anything from old AIX to the latest Linux distribution. Perl is available on all of these platforms. Writing these scripts in Perl so that they will work everywhere is easier than using the shell.

    As has been mentioned CPAN cannot be understated. Thousands of hours can be saved by using code from CPAN.

Re: Argument for Perl ( again and again )
by pvaldes (Chaplain) on Oct 17, 2012 at 18:09 UTC

    It depends on the context and the tribe, I suppose.

    I like Perl, don't dislike at all Python, although I agree that can be a little too much friable when copypasted and basically can do "the same" as perl. I'm interested also in sql, and enjoy a salt of Lisp in my diet here and there. I use perl, sql and lisp every day, and growing interest. So you can tell me about "dead" languajes

    Works for me.

    My interest in learning java is the same as the last years; very low and not growing at all. I can't solve my problems with java, at least currently

    My interest in learning PHP is even lower than Java. Much better (for me) to invest more time in C, Perl, Python or Lisp before.

Re: Argument for Perl ( again and again )
by afoken (Abbot) on Oct 19, 2012 at 18:04 UTC

    I think the main question is: Does the language get the job done?

    The last six months, I've reworked a 30 years old legacy system written in MUMPS to use some state-of-the-art hardware. Low-level drivers for the hardware were delivered as DLLs written in C, High-level drivers came wrapped as Java classes, using JNI and Python wrapped in Java. High-level communication uses hexdumps wrapped in XML. My first attempt was to use the low-level interface and a MUMPS-C-Interface, but that failed because the low-level interface is essentially unuseable. So I tried to embed Java inside the MUMPS process, that failed because of at least two different C runtimes fighting out who owns the processs and who can create threads. Instant crash. The final solution is a TCP server written in Java that communicates with the high-level drivers and translates XML and hexdumps into something that can easily be parsed by MUMPS. The MUMPS process communicates via TCP/IP with the Java TCP server.

    Missing details: A custom C program loads the Java runtime. A big Makefile written for both dmake and GNU make builds everything. Perl to generate some code and the documentation for the MUMPS code, and to test both Java and MUMPS code. Perl also converts legacy data written out by MUMPS as CSV into a new format, generating executable MUMPS code to reconstruct the data in the new format. InnoSetup builds a nice setup.exe, using Pascal for scripting during the setup. And a second Java program, also started via a custom C program, that connects MUMPS to an an external SFTP (SSH) server.

    So, what's the "best" language? I used to say (or even shout) "Perl, because of CPAN, and because it stays out of my way". That's still true for many problems, but in this case, Java was "better" because of the 3rd party high level drivers written in Java. Interfacing those drivers from anything else than Java would have added even more layers of wrappers, making the solution even more complex than it is now.

    I've learned that it can be very helpful to have more than one tool in your toolbox. I use Perl, and I prefer it for many problems, but I have no problem to use C, Java, Javascript, Bash, Pascal, MUMPS, assembler or a Makefile if that solves the problem easier or cleaner than Perl. And when it comes to adapting things that were never designed to fit together, I combine my tools, as shown above.


    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      thomas895++ implies something even more important in Re^3: Argument for Perl ( again and again ):

      You should know your tools, their strengths, and at least as important, their weaknesses. This is so natural to me (coming from a family that has a lot of qualified craftsmen) that I completely forgot to write it down explicitly. Only if you know your tools and your own skills and limits, you can make a reasonable choice. If not, things will end as explained in the current sig of roboticus: "When your only tool is a hammer, all problems look like your thumb."

      (I'm currently trying to add Lua to my set of tools, but too many problems still look like my thumb when I use Lua.)


      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: Argument for Perl ( again and again )
by thomas895 (Chaplain) on Oct 18, 2012 at 23:18 UTC

    What you must realise is that everyone is entitled to their own opinion.

    Arguing about which programming language is a waste of time, because one should use the right tool for the job, and not whatever is "cool".
    Sure, I advocate Perl. I discourage PHP use. I say that Python and Ruby are also useful. That's just my opinion, and I'm pretty sure I could be wrong. For what it's worth, maybe Perl is actually Ierl(Impractical Extraction and Report Language), and I'm wasting my time with my trivial little hacks.
    Who knows?

    At least you won't see me using a 2-claw hammer(in my opinion, that's PHP) to hit a nail into a wall anytime soon, or using a pile-driver(Assembly of some flavour) for that, either.

    confess( "I offer no guarantees on my code." );

      Arguing about which programming language is a waste of time, because one should use the right tool for the job, and not whatever is "cool".

      Pointless arguments with ignoramuses is indeed pointless. Without a deep understanding of the languages you're comparing, how would you know what the right tool for the job is?

        how would you know what the right tool for the job is?
        Well, usually, you pick the right tool from what you already know. Only if that does not work, then you should seek another language, while making sure you like the syntax and philosophy, etc.
        Take me and PHP, for example. At the time I became frustrated with it for lack of readily-available libraries from a central repository, I knew QBasic(bah) and JavaScript. None of those two had anything like CPAN(although I did find JSAN earlier this year), so I stumbled across Perl. And I liked it. So, here I am, using Perl for all my little hacks and a little something I'm writing at the moment.

        confess( "I offer no guarantees on my code." );

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://999252]
Approved by nemesdani
Front-paged by Old_Gray_Bear
[Discipulus]: good morning community!

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2018-06-19 07:06 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.