Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Compile Perl???

by Chris (Novice)
on Mar 04, 2000 at 07:57 UTC ( [id://4860]=perlquestion: print w/replies, xml ) Need Help??

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

Hey, This is just a thought, but does any one know of a way to compile PERL source to object or even binary. If so, what's to speed difference? HOWTO? Inquiring mind wants to know. Thanks in advance for humoring my insanity, Chris

Replies are listed 'Best First'.
Re: Compile Perl???
by Anonymous Monk on Mar 07, 2000 at 01:52 UTC
    perlcc will do make the perl into C. (read the --help CAREFULLY). however, not like one expects. you can compile the C it generates, but dont even think about reading it. as far as i can tell, perlcc doesnt really speed it up drastically, and the only benifit i see is for keeping your perl "closed source" (sorta), as it is near unreadable. if you want to really compile it though, write it in C.
RE: Compile Perl???
by Anonymous Monk on Mar 04, 2000 at 12:34 UTC
    Check out http://www.perl2exe.com/ for converting your perl scripts to stand-alone executable files. Unfortunaltely, perl does not have a perl script to .class file convertor like Python (jpython).
Re: Compile Perl???
by stephen (Priest) on Mar 06, 2000 at 03:16 UTC
    To me, the interesting thing about the lack of an optimizing Perl compiler is the reason why not: because Perl is so heavily based on self-evaluation, a compiler can do little more than embed the Perl interpreter and the code in the same executable.

    In other words, you can't compile a Perl script to object code because Perl thinks in Perl, so you can't take the Perl out of the script.

    From a design perspective, the only way to maintain the flexibility of Perl but maintain C speed is to:

    1. Profile your code to find out where the program is spending its time
    2. If appropriate, rewrite the sucker in C.

    Generally this is unnecessary. Tools like FastCGI and mod_perl give us the ability to skip/reduce the parsing phase while keeping development fast.

    stephen

Re: Compile Perl???
by btrott (Parson) on Mar 04, 2000 at 08:38 UTC
    From perlman:perlfaq3, in the section How can I compile my Perl program into byte code or C?:

    "In general, the compiler will do nothing to make a Perl program smaller, faster, more portable, or more secure. In fact, it will usually hurt all of those. The executable will be bigger, your VM system may take longer to load the whole thing, the binary is fragile and hard to fix, and compilation never stopped software piracy in the form of crackers, viruses, or bootleggers."

    Nevertheless, if you're curious, check it out.

RE: Compile Perl???
by Rydor (Scribe) on Mar 04, 2000 at 22:27 UTC
    i think you can also use perlcc with activestate.
      perlcc is appearently bugged out of it's mind when it comes to WinNT/2000......does anybody have any alternative (FREE) suggestions to this problem........ PS->i know that compilation doesn't really improve anything, but my isp requires my perl stuff to be in executable form......
Re: Compile Perl???
by chromatic (Archbishop) on Mar 05, 2000 at 07:46 UTC
    If you want to speed things up, you'll have better luck examining your algorithms and refining your code. The only time I've ever found it useful to compile my code was when I distributed a tiny, very specialized application to a non-savvy user. If I ever write another Perl program for her, I might as well install the minimal ActiveState distribution.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-22 20:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found