http://qs321.pair.com?node_id=305875

Gorby has asked for the wisdom of the Perl Monks concerning the following question:

Hello Wise Monks. Time and again, people say to me, "Why do you use Perl? Java or ASP is much better". Quite frankly, I feel annoyed everytime they say that but since I don't know much about java or asp, I can't react. Is it true that Perl is inferior to these 2 languages? If not, what should I say to these people? Thanks in advance. Gorby

20031110 Edit by Corion: Changed title from 'What do I say?'

  • Comment on Arguments needed for comparision between Perl, ASP and Java

Replies are listed 'Best First'.
Re: Arguments needed for comparision between Perl, ASP and Java
by rozallin (Curate) on Nov 10, 2003 at 15:02 UTC
    You will find that some programmers can be quite fanatical about their choice of programming language to the point that they no longer see the reasons why anyone should choose another language to program in. And while there may not be that much of a problem with that, programmers sometimes lose sight that the best programming language is the programming language that does what you need it to do quickly and efficiently. The best tool for the job.

    Perl is a very good programming language to solve general-purpose problems involving 90% text and 10% just about everything else. It's used for CGI on websites, it's used with databases, it's used with XML and many other things, as a poke around CPAN or PerlMonks will tell you.

    Java, on the other hand, is a completely different type of programming language, in that it's object-orientated. That doesn't mean that Perl and Java couldn't solve a given problem, but it just means that there are some things Java could do better than Perl, and vice versa.

    ASP is a technology that enables you to make dynamic and interactive web pages, using server-side scripting to dynamically produce web pages that are not affected by the type of browser the web site visitor is using. The default scripting language used for writing ASP is VBScript, although you can use other scripting languages like JScript (Microsoft's version of JavaScript). Perl can do what ASP can do, but Perl is more general-purpose than ASP.

    If you really want to know whether Perl is better than language x, learn them both (or, even better, persuade those who prefer language x to learn Perl :) ) and try to solve the same problem in both of the languages, and then see which one you start to use more when tasks need to be done.

    And remember, if there was a superior programming language, everyone who's anyone would be using it ;)

    --
    rozallin j. thompson
    The Webmistress who doesn't hesitate to use strict;

      I'd just like to add that you can even use Perl with ASP, via either Apache::ASP, or by installing PerlScript on an IIS server.

      bbfu
      Black flowers blossom
      Fearless on my breath

      I'm afraid I take issue with several of your points:

      Java, on the other hand, is a completely different type of programming language, in that it's object-orientated. That doesn't mean that Perl and Java couldn't solve a given problem, but it just means that there are some things Java could do better than Perl, and vice versa.

      A) I don't think you can call any language 'object oriented'. OO is a design style, not a function of the language. You can write OO code in C and write procedural code in java. Granted in general it's much easier to write OO in java and procedural in C, but it doesn't make C a 'procedural language' or java an OO language.

      B) Perl has just as many OO'ish features as java does, you could write every single thing as a class if you wanted to. (Well, except for a line that looked like package main; new module;.)

      C) If you really wanted to find the differences you should note that java is a much lower level/stricter programming language, meaning that you have to manually deal with datatypes such as int or char, and once you declare something an int it stays an int and so on. (lets not get in to scalar datatypes, or object inheritance issues). Java has a number of other differences but I find that to be the most important one.

      ASP is a technology that enables you to make dynamic and interactive web pages, using server-side scripting to dynamically produce web pages that are not affected by the type of browser the web site visitor is using. The default scripting language used for writing ASP is VBScript, although you can use other scripting languages like JScript (Microsoft's version of JavaScript). Perl can do what ASP can do, but Perl is more general-purpose than ASP.
      ASP, atleast in my somewhat limited understanding, is a frame work for CGI type applications that allows a number of different languages access to a number of basic methods and data, such as form data and session handling (I think). It also lets these different languages work together much closer then without it, passing datastructures back and forth and so on (Again, I think).
        A) I don't think you can call any language 'object oriented'. OO is a design style, not a function of the language. You can write OO code in C and write procedural code in java. Granted in general it's much easier to write OO in java and procedural in C, but it doesn't make C a 'procedural language' or java an OO language.

        A) Oh, I think you can. An OO language is one that supports object oriented semantics at the language level. Java does, C does not. I will agree that one can program in either an OO or procedural style in either language, but that doesn't make Java more procedural nor C more OO.

        C) I also agree that Java's meaningful differences from Perl have nothing to do with OO. But 'static' vs 'dynamic', comes to mind.

Re: Arguments needed for comparision between Perl, ASP and Java
by batkins (Chaplain) on Nov 10, 2003 at 15:11 UTC
    Turn the question back around and ask them the same thing.

    And here are some advantages Perl has over ASP and Java (to throw at them while they're still trying to come up with some good reasons for their preferred languages):

    • Built-in text processing facilities - regexen, split, etc.
    • CPAN - there's probably a module on CPAN that will do what you need, and will do it a lot more reliably since most CPAN modules are subjected to more testing than a handrolled module.
    • Communities like PerlMonks
    • And most importantly, a saner syntax. For example, let's open a file in Perl and write to it:
      open my $fh, ">FILENAME" or die "Can't write FILENAME: $!"; print $fh "We are writing a line of text to a file.\nSecond line"; close $fh;
      In ASP:
      <% Dim objFSO, objTextStream, file file = Server.MapPath("samplefile.txt") Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set objTextStream = objFSO.OpenTextFile(file , 2, True) objTextStream.WriteLine "We are writing a line of text to our text fil +e" & VBCfLf & "This is our second line of text" & VBCrLf objTextStream.Close Set objTextStream = Nothing Set objFSO = Nothing %>
      Or Java:
      try { BufferedWriter out = new BufferedWriter(new FileWriter("outfil +ename")); out.write("We are writing a line of text to our text file\nThi +s is our second line of text"); out.close(); } catch (IOException e) { }
      I know which one I'd rather write. The Java example isn't as ludicrously verbose as the ASP sample, but I still find Perl's syntax much more straightforward.
    • Perl's interpreter is extremely fast. If you run Perl with mod_perl or ISAPI, you'll get excellent performance. I would suspect this is faster than ASP and strongly suspect that this is faster than Java, but I have no numbers to prove this.
    Are you sure it was a book? Are you sure it wasn't.....nothing?

      Those are perfect examples of the difference in philosophy between Perl and many other languages. Common things should be as simple as possible. I've always had fun with those whose Java is a little shaky by asking them them to write the code for opening and writing to a file without looking up the syntax. It's surprising how many people blow it.

      Now how many people have the same problem in Perl?

      Cheers,
      Ovid

      New address of my CGI Course.

        I would say that each language is better for something (even though a problem can be solved in any language).
        Also, one advantage in Perl is that it can be modified on the fly.
        Say for example, if it is written in Java, you would have shipped the class files to your client. If there is a bug and you want to fix it at site (not that you will be allowed to do it in all cases), you can't do it. You have to check it out from your repository, make changes, compile, build and ship the class files to the client site in order to fix the bug.
        If it is written in perl, you just edit it, make changes, and run it!

        Also if you know several languages, you could look at the problem and say "language Y is probably the best candidate for this problem"

      in all fairness to ASP. you could have written it shorter and you wrote some things in the ASP one that weren't in the perl one.
      <% Dim objFSO, objTextStream, file file = Server.MapPath("samplefile.txt") Set objFSO = Server.CreateObject("Scripting.FileSystemObject") Set objTextStream = objFSO.OpenTextFile(file , 2, True) #If I'm not mistaken you can bump these two writes into one. objTextStream.WriteLine "We are writing a line of text to our text fil +e" objTextStream.Write "This is our second line of text" & VBCrLf #You didn't echo in the perl example Response.Write "we have written to our text file" objTextStream.Close #Are these neccesary ? Set objTextStream = Nothing Set objFSO = Nothing %>
      I myself don't do much ASP or know enough about it to call it "superior" to anything, but let's be fair in our comparison.
        Fair enough (no pun intended). I've removed the echo and combined the two Response.Write calls. However, the last two lines are necessary - the Perl version closes the filehandle, so the ASP version should do the same.
        Are you sure it was a book? Are you sure it wasn't.....nothing?
      I prefer advocacy that doesn't provide bad examples of how to do it.

      Please add the standard  or die "Can't write FILENAME: $!" to your open for the exact reasons that are discussed in perlstyle.

        OK, I've changed it.
        Are you sure it was a book? Are you sure it wasn't.....nothing?
        Yes, but then you are providing error checking. Does the asp example provide error checking? Doesn't look that way to me, thus for a fair comparison you should omit the  or die "blah". The point is to compare code with the same function, ya?
Re: Arguments needed for comparision between Perl, ASP and Java
by jasonk (Parson) on Nov 10, 2003 at 14:58 UTC

    When people tell me that Java or ASP is better than Perl, I generally just give them the same funny look I would have given them if they had said something as profound as "Why do you wear a hat when an elephant is so much better?" or "Why do you use Perl when you could be swimming?" I don't feel like I need to justify my choice in languages, most people don't buy a car based on what tools were used to build it, if you are the programmer, the choice of tools should be up to you, other people only need to worry about the end result.


    We're not surrounded, we're in a target-rich environment!
Re: Arguments needed for comparision between Perl, ASP and Java
by Art_XIV (Hermit) on Nov 10, 2003 at 16:51 UTC

    Having worked w/Perl, Java/JSP, and ASP/ASP.NET, I can sincerely state the following - Java and/or ASP are better because Sun/IBM/Microsoft have multi-million dollar marketing budgets that say they're better.

    It's not unusual for developers to be passionate about languages and prejudiced in favor of or against various languages. I guess this is a side-effect of so many developers being INTJs. ;)

    Bold generalizations follow, but I try to make them with an open mind and sense of fairness:

    • A Perl app can be written much faster than any comparable Java/.NET app when written by developers of comparable skill.
    • A Perl app will tend to run a little slower than a comparable Java (1.3 +)/.NET app when written by highly skilled developers.
    • Its anybody's guess how the performance of apps will compare when written by relatively low-skilled developers. Java and .NET have many performance traps for novice/indifferent developers. If I had a dollar for all the string-concatenation in loop problems, inappropriate use of reflection problems, poor use of the database problems, etc... that I've seen w/ Java and .NET, I'd have at least a mortgage payment. And I'm only counting code written by 'professional' developers.
    • Code quality has very little difference. Perl may even have an edge in many cases since it's so easy to get Perl to do what you want it to do w/o funky work-arounds or extra reams of code.
    • Maintainability is harder to assess. It can be hard for a team of developers to work with Perl, but its hard for a team to work in any language. Communication and documentation are what counts, here. Perl can be a 'Write-Once, Run-Only' language when it's written to be such, but it can be very understandable when written to be such.

    The performance, quality, and maintainablity of any application is going to spring much more from the skill, talent, dedication and self-discipline of the developer(s) and the amount of quality design time that is put in than it will from the language/platform choice. Developers can produce something beautiful with Perl, Java, or .NET. They can also produce slow-running, unmaintainable crap with any of the three.

    When someone asks me 'Why do you use Perl? Java or ASP is much better.', I ask them 'How did you come to that conclusion? Have you used both Perl and <language/platform x>?'

    80 percent of the time the response is "No", possibly with some baloney about how CGI has to spawn a new process or "Perl is too hard to understand" or "Perl looks like line noise" or some hooey along the same lines.

    Have no doubt that I like Perl, and I like it alot. Putting more tangible qualities aside, writing Perl is a lot more fun than writing Java or .NET. And fun matters when you spend all day coding. Perl values my time more. Perl doesn't make me sweat over the mundane. Perl is easy to learn yet difficult to master. Perl helps make the journey as enjoyable as the destination.

    Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"
Re: Arguments needed for comparision between Perl, ASP and Java
by Abigail-II (Bishop) on Nov 10, 2003 at 16:11 UTC
    Is it true that Perl is inferior to these 2 languages?
    Yes. On the last list of language (all 5478 of them) which was ranked from superiour to inferiour Perl was way below Java or ASP. In the 49 years that this list was published by the ACM, noone has ever questioned its ranking.

    In an article discussing this list, prof. J. K. M. W Blitznekowska said that she expected perlmonks.org to close shop before then end of the year.

    Abigail

      Of course, "P" comes after both "A" and "J" in the alphabet ;-)


      "Ex libris un peut de tout"
      Is this available online?

      Are you sure it was a book? Are you sure it wasn't.....nothing?

        Unfortunately no. The fine professor's app server ran out of RAM and they're waiting to install a new 2.5 tier component cache.

      You can say what you like, but for its particular problem domain, nothing beats HQ9+. And it even runs under parrot.
Re: Arguments needed for comparision between Perl, ASP and Java
by rdfield (Priest) on Nov 10, 2003 at 15:35 UTC
    "Well, I suppose that <insert other language here> is OK for beginners, but when you know what you're doing and just want to get the job done nothing beats Perl". Ignore any follow-up questions :)

    rdfield

Re: Arguments needed for comparision between Perl, ASP and Java
by perrin (Chancellor) on Nov 10, 2003 at 15:23 UTC
    If you punch "Java" into SuperSearch, you will find many posts that discuss Java in relation to Perl. Most people write ASP in VBScript, and only an ignorant person would claim that VBScript was better than much of anything.
Re: Arguments needed for comparision between Perl, ASP and Java
by jdtoronto (Prior) on Nov 10, 2003 at 19:45 UTC
    Why say anything?

    Religious fervour is a wonderful thing, in the right place (I think?). But to my waty of thinking it has no real p0lace in programming. Or does it? Ever since the beginning of my own career over thirty years ago I have seen this over and over and over again. 'C' vs Assembler, TimeSHare Basic vs Fortran, Algol vs APL, modular code vs object orientation, you name it, we have fought battles long and loquacious over it.

    Any language is as useful as you make it. Perl has advatages, but then so does 'C' in some places, maybe VB has in others (althought I can;t think of any right now!) Well I remember a major software product of my own, in the 1980's my colleagues and I raged a heated battle over whether we should re-write in 'C' or Pascal. We tried both. About the same amount of code, about the same number of major headaches, roughly the same volume of swearing, cursing and abuse from the programming teams.

    Eventually I sold the product, it was in Borland C++ at the time and has been maintained and enhanced in that environment ever since. But now it is getting old, the original foundation for the C++ version was actually written in Borland Turbo-C/C++ 4.5! So the developers are saying they want to move it to something else. But what? Well thats why I got a call a few weeks ago. I have been contributing algorithms and mathematics to the developers ever since I sold it, they asked what I was ciurrently using to prove algorithms and validate my models. There was stunned silence when I said, "Perl and PDL".

    So I expect that the developers will get their way and rewrite the whole thing in Java. The estimated budget is $7 million US dollars. Well good luck guys, the product used to sell for $5,000 6 years ago. It now sells for $285,000. The president of the company told me he has no idea what it will sell for in the new version, but he did suggest that they would, quite naturally "supply the equipment it was to run on as part of the price". So hey, they dont need platform independence, they just need a platform to run on. When I asked why they wanted to use Java he said "well, I can afford to lose the Director of Product Development, and he wants to do it in Java."

    About as good a reason as any I have heard for choosing a language!

    jdtoronto

Re: Arguments needed for comparision between Perl, ASP and Java
by Roy Johnson (Monsignor) on Nov 10, 2003 at 16:42 UTC
    Time and again, people say to me, "Why do you use Perl? Java or ASP is much better".
    They've made a claim, so they should back it up. It's not incumbent on you to assume they're right until you can prove them wrong.

    Better for what? By what measures?

Re: Arguments needed for comparision between Perl, ASP and Java
by Solo (Deacon) on Nov 10, 2003 at 20:21 UTC
Re: Arguments needed for comparision between Perl, ASP and Java
by inman (Curate) on Nov 10, 2003 at 17:32 UTC
    If you are writing applications that support a web site then you could probably choose any of the languages mentioned. Each offers a number of advantages and disadvantages that need to be considered. Many have been covered in this thread but here are a couple of mine!

    If you are developing code for yourself (school / college project, hobby etc.) then you should use whichever language you like / know best. If you are developing code for someone else then you should choose the tools that are known by the majority of the coders or technical staff so that the code can be maintained and supported after you are gone.

    Code in an environment that is best suited to your target environment. Most hosting companies support ASP by way of ChilliSoft but a perl script might be easier to deploy.

    Whichever language you choose to develop stuff in - enjoy yourself while you do it!

    inman

      If you are developing code for someone else then you should choose the tools that are known by the majority of the coders or technical staff so that the code can be maintained and supported after you are gone.

      <Joke>

      Now why would you ever do that? It's much better to ensure that the written contract declares that any maintaining done by you will cost extra (ie: not included in the project price itself). You then code the project using methods that could only ever make sense to yourself. Presto, you will now be called in for all required maintenance and some extra money in your pocket!

      </Joke>

Re: Arguments needed for comparision between Perl, ASP and Java
by Zed_Lopez (Chaplain) on Nov 10, 2003 at 18:42 UTC
    In your case, I suggest "Because I know Perl and I don't know Java or ASP." (That's among the reasons I don't use a large number of languages that aren't Perl.)
Re: What do I say?
by Roger (Parson) on Nov 11, 2003 at 03:33 UTC
    Java works the same way Perl does, except you might pre-compile Java source into Perl to reduce a bit of overhead on start time.

    Performance-wise, Java is roughly the same speed as Perl. But, but, I would prefer Perl's powerful regexp, flexibility and clever idioms.

    ASP? I can't see the comparison here. ASP vs CGI, not Perl. To compare ASP with Perl is like compare an apple to an orange. There is CGI mod_perl and there is also ASP Perl. You can do ASP in VB, VC, Perl etc. And the ASP syntaxing is ugly (my personal opinion and taste), the IIS has too many security holes.

    Perl is not inferior to Java or ASP.