A simple doubt :-/

Discussion in 'Perl Misc' started by Vijoy Varghese, Aug 8, 2003.

  1. Hello Group

    I have a doubt.

    The programs written in 'C' language *.c is compiled to *.obj and then
    linked to *.exe which is the 'machine language' substitute for our *.c
    program, right? Now for a processor to execute any program, the
    program should be coded in a language which the processor can
    understand, and here in our case the *.exe is such a language (or may
    be one level above the 'language processor can understand', and our
    Operating System does the translation work for the processor). So what
    ever it be, the *.exe is close to the language which the processor can
    understand.

    Now, a CGI program written in Perl, *.cgi there is no compilation or
    linking. That is each time we try to activate this program the Perl
    interpreter have to convert it to the *.exe format(or directly to hard
    core machine language of 0's and 1's?) and this process is repeated
    during all activation of the *.cgi script, right?

    So this is a kind of overhead when a same script is activated some
    1000 time in a minute, right? But still people are using Perl for CGI
    scripting, why? Yes, Perl is fun, its always fun to program using a
    language which remind us more of a 'natural language' rather than a
    'programming language'. But still, why don’t some one make a
    'Compiled Perl' with all features of current Perl, but which can be
    compiled to machine language, so that there is no need to 'translate'
    it each time its activated.

    Or is there is already one available? I have heard a lot about
    'mod_perl' and that it increases the speed of CGI scripts by some 100
    times. Is that have something to do with the 'compiled' version :-/

    I am expecting a lot of '@#$#$%$@' replies, because I know this is not
    the way to ask questions in a group. But friends, this doubt... its
    hunting me for a long time, and i cant find a convincing answer
    anywhere. :-(

    Waiting for your replies or some pointers where I can find answer to
    my doubt.

    Thanking you all

    Regards
    Vijoy Varghese
    Vijoy Varghese, Aug 8, 2003
    #1
    1. Advertising

  2. (Vijoy Varghese) writes:


    > The programs written in 'C' language *.c is compiled...


    [snip how compiled lanuages work ]

    > Now, a CGI program written in Perl, *.cgi there is no compilation or
    > linking. That is each time we try to activate this program the Perl
    > interpreter have to convert it to the *.exe format(or directly to hard
    > core machine language of 0's and 1's?) and this process is repeated
    > during all activation of the *.cgi script, right?


    Actually in converts it into an intermediate form - Perl byte code.
    The Perl by code is then interpreted by a virtual machine.

    > So this is a kind of overhead when a same script is activated some
    > 1000 time in a minute, right? But still people are using Perl for CGI
    > scripting, why?


    Be aware that a lot of the overhead is also in the process creation
    overhead. Even if you use native executable CGIs you still have to
    pay.

    If you want speed one way is to load your web server apps into the
    web server itself. For example, in Apache you do this with Apache
    loadable modules.

    > Yes, Perl is fun, its always fun to program using a
    > language which remind us more of a 'natural language' rather than a
    > 'programming language'. But still, why don’t some one make a
    > 'Compiled Perl' with all features of current Perl, but which can be
    > compiled to machine language, so that there is no need to 'translate'
    > it each time its activated.


    Attempts have been made but they've not managed to produce significant
    speed improvements.

    > Or is there is already one available?


    There are, AFAIK, no production-ready Perl compilers or byte-code loaders.

    > I have heard a lot about 'mod_perl' and that it increases the speed
    > of CGI scripts by some 100 times. Is that have something to do with
    > the 'compiled' version :-/


    Yes. In Apache mod_perl the Perl interpreter is kept running and not
    restarted for each web transaction so once any module (or pseudo CGI
    script) has been loaded and compiled once it need not be again until
    the web server is restarted. Actually there's a pool of several Perl
    interpreters servicing requests so each module is compiled once for
    each interpreter. Also because Perl programs sometime leak memory
    each interpreter is killed off and replaced periodically.

    If you know in advance what modules are going to be used the you can
    preload them at server startup and then they don't need to be loaded
    during the first transaction that needs them.

    Be aware that mod_perl is not CGI. It is possible to write Perl
    source code that can run both as CGI scripts and as mod_perl handler
    modules using the 'Registry' mechanisms provided by mod_perl. This is
    the mode in which most people (including myself) use mod_perl most of
    the time. Such programs need to obey a few simple rules above and
    beyond those which real CGI scripts would.

    However you can do a lot more in mod_perl than you can in CGI.

    Also running mod_perl in the mode where in can use these dual-role
    programs will slow it down.

    For information about Apache+mod_perl go see the Apache+mod_perl
    websites. (Like, D'uh!).

    There's some real exciting stuff in Apache2+mod_perl2.

    Note: there are other alternatives to CGI that also eleminiate the
    process creation-per-transation overhead, e.g. FastCGI.

    --
    \\ ( )
    . _\\__[oo
    .__/ \\ /\@
    . l___\\
    # ll l\\
    ###LL LL\\
    Brian McCauley, Aug 8, 2003
    #2
    1. Advertising

  3. Vijoy Varghese

    Sam Holden Guest

    On Fri, 8 Aug 2003 19:20:49 +0000 (UTC),
    Louis Erickson <> wrote:
    >
    > I haven't found a way to use mod_perl that wasn't horribly difficult.
    > This may be my missing something obvious, and if it is, I'd very much
    > love to be hit with the clue stick. None of the tutorials or documentation
    > I've seen talks about how to take a functioning, cleanly written CGI
    > program and make it run correctly under mod_perl.


    http://perl.apache.org/docs/1.0/guide/porting.html

    Covers most of the issues with moving from CGI to mod_perl. Though
    you've probably read it.


    --
    Sam Holden
    Sam Holden, Aug 10, 2003
    #3
  4. Vijoy Varghese

    pkent Guest

    In article <>,
    (Sam Holden) wrote:

    > On Fri, 8 Aug 2003 19:20:49 +0000 (UTC),
    > Louis Erickson <> wrote:
    > >
    > > I haven't found a way to use mod_perl that wasn't horribly difficult.
    > > This may be my missing something obvious, and if it is, I'd very much
    > > love to be hit with the clue stick. None of the tutorials or documentation
    > > I've seen talks about how to take a functioning, cleanly written CGI
    > > program and make it run correctly under mod_perl.


    IME if your program really is a cleanly written CGI it runs Just Fine
    under mod_perl. But if that's not your experience I fully second the
    recommendation of:

    > http://perl.apache.org/docs/1.0/guide/porting.html


    My hint would be to completely ignore handlers and Apache::* stuff until
    you're au fait with the environment... and even then only if you really
    want to or need to. I've very very rarely had to do anything other that
    required mod_perl handlers, for example. At my place we write stuff so
    that it runs as a CGI or under mod_perl just the same, with no changes
    (of course running it under mod_perl is generally faster and more
    efficient and so on)

    P

    --
    pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
    Remove the tea to reply
    pkent, Aug 10, 2003
    #4
  5. Vijoy Varghese

    test Guest

    Help : from file system structure to topic maps format

    Hello,



    I want to make a little script in perl .
    .... but I'm very newbie in this langage



    For each sub-directory of a given directory ...

    (and for each file in the directory)

    .... I want to write in a file something like that :




    < <topic>
    <baseName>
    <baseNameString>nameOfTheSubDirectory</baseNameString>
    </baseName>
    <occurrence>
    <resourceRef
    xlink:href="file:///fullNameOfTheFirstFileInTheSubDirectory"/>
    </occurrence>
    <occurrence>
    <resourceRef
    xlink:href="file:///fullNameOfTheSecondInTheSubDirectory"/>
    </occurrence>
    ...
    <occurrence>
    < resourceRef
    xlink:href="fille:///nameOfTheLastFileInTheSubDirectory"/ >
    </occurrence>
    </topic>



    (Where fullNameOfEachFile is the name of the file with his path)



    Any idea to help me to start ?



    Regards



    Bernard
    test, Aug 13, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rafael Veronezi

    Response.Write simple doubt

    Rafael Veronezi, Oct 14, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    321
    Marina
    Oct 14, 2003
  2. Bob Nelson

    doubt about doubt

    Bob Nelson, Jul 28, 2006, in forum: C Programming
    Replies:
    11
    Views:
    595
  3. Replies:
    0
    Views:
    539
  4. Peter Otten
    Replies:
    2
    Views:
    103
    Cousin Stanley
    Aug 10, 2013
  5. Terry Reedy
    Replies:
    0
    Views:
    106
    Terry Reedy
    Aug 10, 2013
Loading...

Share This Page