Interpreted or compiled -- Perl efficiency 
Author Message
 Interpreted or compiled -- Perl efficiency

Hi there,

I have been trying to figure out just exactly what it means to run a
perl script.

The glossary of the Camel book suggests that by def'n, Perl is
neither strictly compiled nor interpreted.
"The perl process involves taking a program and turning it into a more
executable form -- syntax trees."

My questions is:

        Is this intermediate form (syntax trees) regenerated each
        time the perl script is executed (even if no modifications have
        been made)?

Ultimately I would like to determine when efficiency is a large enough
factor to write a program in C as opposed to Perl.
(i.e. Ignoring programming style, just how efficient is Perl?)

Thanks in advance,
Jason



Fri, 07 Mar 1997 21:46:21 GMT  
 Interpreted or compiled -- Perl efficiency


Quote:
>My questions is:

>    Is this intermediate form (syntax trees) regenerated each
>    time the perl script is executed (even if no modifications have
>    been made)?

Yes...  unless you use the dump/undump/unexec stuff to capture a core
image and turn it into an executable.

Quote:
>Ultimately I would like to determine when efficiency is a large enough
>factor to write a program in C as opposed to Perl.
>(i.e. Ignoring programming style, just how efficient is Perl?)

It seems to me that perl is pretty fast at compiling a script into an
internal representation, you might want to try using time (if you're on a
unixish system) and some judiciously placed exit statements to see how
long it takes to load & compile your program and then just quit and how
long it takes to load, compile and then do the work.  Then you'll have to
decide at what point the overhead is too large, this will depend on if
your program is fired up once a week and runs for hours or if it's
something like a daemon forked off by inetd which could be run many times
a second but each run is really short...

Mike

--
The "usual disclaimers" apply.    | Meiko
Mike Stok                         | 130C Baker Ave. Ext

Meiko tel: (508) 371 0088 x124    |



Sat, 08 Mar 1997 20:08:06 GMT  
 Interpreted or compiled -- Perl efficiency

Quote:
>Ultimately I would like to determine when efficiency is a large enough
>factor to write a program in C as opposed to Perl.
>(i.e. Ignoring programming style, just how efficient is Perl?)

The perl "compiler" is pretty fast.  If your program is of significant
size, most of the time will be spent executing the code, not compiling.
The internal format is interpreted pretty easily.

For the kinds of things Perl is good for, you're probably going to spend
much of your time in library routines, like the regular expression matcher,
or external processes called with system() or ``.  The time spent in these
routines is independent of whether the caller is compiled or interpreted.

A couple of months ago I converted a C program of around 1-2K lines to a
Perl program of about 150-200 lines.  I initially had some performance
problems in the Perl version.  I made a small change to the algorithm, and
the performance of the Perl version was about the same as the C version.
In addition, the Perl version had some additional features and was (IMHO)
more maintainable.
--

Barry Margolin
BBN Internet Services Corp.



Sun, 09 Mar 1997 00:22:49 GMT  
 Interpreted or compiled -- Perl efficiency

: I rewrote make in perl5.  Its about 1500 lines now and the compile
: time is about 1.5-2 seconds.  Barely acceptable.  As it grows to 2K
: lines, the compile time will probably become unacceptable.

Hmmm.  That's a bit strange.  I wrote a make-like tool with dynamic
dependency derivation and distributed parallel build, integrated with
configuration management.  1800 lines of xscheme-like code.  It loads in
0.1 CPU second, and far less than a second realtime.

Now, granted, perl is lexically difficult (he understated).
But that much different?

: Perl5 is a real, full-blow, OOP language.

A nice, persistent object store with clean semantics, too?  Classes with
inheritance, simple persistent object store, and interpreter speed were
largely what made me choose a more... regular shall we say, scripting
language than perl4 for configuration management scripting.

I wish perl5 had been there then.  I really do.
--




Sun, 09 Mar 1997 08:08:18 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Interpreted or compiled -- Perl efficienc

2. perl: interpreted and/or compiled?

3. Compile Time Efficiency

4. Different Perl executable needed to interpret cygwin paths!

5. Easy way to interpret perl literals embedded in files

6. In fact is Perl really an interpreted language?

7. perl script interpreted in a C++ application

8. perl script interpreted in a C++ application

9. If Perl interprets source why is there a need to compile Perl modules??

10. Perl.exe has an interpreted mode?

11. perl to interpret a XLS file?

12. C code to interpret Perl scripts?

 

 
Powered by phpBB® Forum Software