Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

When to use Java?

by Willman023 (Scribe)
on Nov 19, 2002 at 12:47 UTC ( [id://214095]=perlquestion: print w/replies, xml ) Need Help??

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

Fellow Monks,

Now I know this isn't javamonks, but I feel I must ask this question...specially when I have to reprogram a Perl program in Java :(. Our project manager and a panel of other web experts have decided that we need to port our database intensive program over to Java due to performance issues. I requested to see just how slow the difference was and was amazed at the difference. On two similar pages one generated in Perl and one in Java, where it pulls about 6000 DB entries and displays them on a page it took the Perl program about 22 seconds and the Java applet about 4 seconds. Our project manager explained that Java applets reside in memory(cache), where Perl an interpreted language is fired up each time the program is run, and this is where he accounted for the efficiency differences. So my question goes, how do you know when to use Java over Perl? And is it more likely that the Perl code is just inefficient and that's why its so slow?

bW

Replies are listed 'Best First'.
Re: When to use Java?
by ajt (Prior) on Nov 19, 2002 at 13:03 UTC
Re: When to use Java?
by UnderMine (Friar) on Nov 19, 2002 at 13:07 UTC
    Other things to look at are :-

    A. Apache::DBI in order to have persistant connections.

    B. Binding variables to place holders.

    C. mod_perl

    D. correct DBD driver ie use DBD::Oracle not DBD::ODBC to the Microsoft Oracle driver. (This one is a classic as MS screwed the Oracle driver for their own reasons)

    A Code sample would allow us to see if there were any mistakes that were causing CPU spin etc

    Hope this Helps
    UnderMine

Re: When to use Java?
by rdfield (Priest) on Nov 19, 2002 at 12:53 UTC
    You might want to read the Guide. There is no need to start up a Perl interpreter for each request, use mod_perl instead.

    rdfield

Re: When to use Java?
by PodMaster (Abbot) on Nov 19, 2002 at 13:10 UTC
    Most folks guessed you were talking about a CGI enviroment, but I refuse to make such an assumption, so i ask you, is that the case?

    You say applet, so you're comparing a java applet to a perl/cgi program? (comparing clientside=java, to serverside=perl)

    Please clairfy.

    ____________________________________________________
    ** The Third rule of perl club is a statement of fact: pod is sexy.

      Well, the assumption was correct. We are using CGI. But the problem is we use iPlanet webserver and I'm told mod_Perl is only supported on Apache. And I'm not sure about it being an applet, it is serverside Java so I guess its not.

      bW

        The problem here is not with Perl but with CGI. Your situation is comparing CGI to Servlets/JSP and the differences between the two mean that Servlets will normally win on performance.

        Mod_perl is for apache so yes, you won't get it to run on IPlanet. However, I think it is a little harsh to consider re-writing the whole app. Have you considered writing a middleware server that abstracts all your database code?

        That way you can keep a large majority of your existing database code (plus abstract your database from your view) and then just re-write your view? I've used this approach with great success here but, peversely, in reverse with a Java backend and Perl frontend. Just my 2p :)
        If you are using iPlanet on a Windows box then PerlEx may solve your problem with no recoding.. worth a look at least.

        Hope it helps
        UnderMine

        You might also want to take a look at CGI::Fast, PPerl and PersistentPerl - three alternatives to mod_perl for solving initialisation time issues.

        (mod_perl solves other problems too, but not relevant here :-)

        I work with bW......we are using java servlets on Iplanet.
        ---------------------------
        In closing, Screw Flanders.
Re: When to use Java?
by Nitrox (Chaplain) on Nov 19, 2002 at 13:21 UTC
    I read some place (and it became my mantra) that the best way to *really* learn Perl was to use it in everything you do, even when another language might be a better/easier fit. :-)

    -Nitrox

      My only exception is to use Flash when neccessary for a web client user interface. Client side Perl support is not too good but generally there is no real need for Java these days with Flash being so well supported and firewalls stripping Java and ActiveX.

      Hope it helps
      UnderMine

        ...only exception is to use Flash when neccessary...
        The response to which is, It is never necessary to use Flash.
        (a) Flash is not that well supported, and
        (b) proxies are as likely, if not more so, to strip out Flash as to strip out Java or ActiveX.

        Of course, it's not really "never". If you're developing for an intranet, and you can count on all your clients having Flash properly installed, and the proxies not stripping it, then fine; use Flash. Otherwise -- well, disregard usability issues at your own risk.

        Flash is NOT web. Web is not Flash.

        </rant>

        jdporter
        ...porque es dificil estar guapo y blanco.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://214095]
Approved by robartes
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (1)
As of 2024-04-25 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found