cvs commit: perlfaq perlfaq3.pod
[email protected] (brian d foy) 21 Jan 2005 12:08:04 -0000
| Newsgroups | perl.cvs.perlfaq |
|---|---|
| Message-ID | <[email protected]> |
cvsuser 05/01/21 04:08:04
Modified: . perlfaq3.pod
Log:
* How can I compile my Perl program into byte code or C?
+ I completely replaced the answer to update it for this
millineum :)
+ Mention Perl2Exe, Perl Dev Kit, PAR, and B::Bytecode
+ I assume the real question is "How can I bundle everything
in one file" or "How do I hide my source?"
+ Point to "How can I make my Perl program run faster?"
in case that's really what they want
+ Along with this, I think we should update the answers
on making Perl run faster and hiding source code, but I'll
save those for another day.
Revision Changes Path
1.44 +35 -36 perlfaq/perlfaq3.pod
Index: perlfaq3.pod
===================================================================
RCS file: /cvs/public/perlfaq/perlfaq3.pod,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- perlfaq3.pod 3 Jan 2005 18:43:37 -0000 1.43
+++ perlfaq3.pod 21 Jan 2005 12:08:04 -0000 1.44
@@ -1,6 +1,6 @@
=head1 NAME
-perlfaq3 - Programming Tools ($Revision: 1.43 $, $Date: 2005/01/03 18:43:37 $)
+perlfaq3 - Programming Tools ($Revision: 1.44 $, $Date: 2005/01/21 12:08:04 $)
=head1 DESCRIPTION
@@ -753,41 +753,40 @@
=head2 How can I compile my Perl program into byte code or C?
-Malcolm Beattie has written a multifunction backend compiler,
-available from CPAN, that can do both these things. It is included
-in the perl5.005 release, but is still considered experimental.
-This means it's fun to play with if you're a programmer but not
-really for people looking for turn-key solutions.
-
-Merely compiling into C does not in and of itself guarantee that your
-code will run very much faster. That's because except for lucky cases
-where a lot of native type inferencing is possible, the normal Perl
-run-time system is still present and so your program will take just as
-long to run and be just as big. Most programs save little more than
-compilation time, leaving execution no more than 10-30% faster. A few
-rare programs actually benefit significantly (even running several times
-faster), but this takes some tweaking of your code.
-
-You'll probably be astonished to learn that the current version of the
-compiler generates a compiled form of your script whose executable is
-just as big as the original perl executable, and then some. That's
-because as currently written, all programs are prepared for a full
-eval() statement. You can tremendously reduce this cost by building a
-shared I<libperl.so> library and linking against that. See the
-F<INSTALL> podfile in the Perl source distribution for details. If
-you link your main perl binary with this, it will make it minuscule.
-For example, on one author's system, F</usr/bin/perl> is only 11k in
-size!
-
-In general, the compiler will do nothing to make a Perl program smaller,
-faster, more portable, or more secure. In fact, it can make your
-situation worse. 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. The real advantage of the compiler is merely
-packaging, and once you see the size of what it makes (well, unless
-you use a shared I<libperl.so>), you'll probably want a complete
-Perl install anyway.
+(contributed by brian d foy)
+
+In general, you can't do this. There are some things that may work
+for your situation though. People usually ask this question
+because they want to distribute their works without giving away
+the source code, and most solutions trade disk space for convenience.
+You probably won't see much of a speed increase either, since most
+solutions simply bundle a Perl interpreter in the final product
+(but see L<How can I make my Perl program run faster?>).
+
+The Perl Archive Toolkit (http://par.perl.org/index.cgi) is
+Perl's analog to Java's JAR. It's freely available and on
+CPAN (http://search.cpan.org/dist/PAR/).
+
+The B::* namespace, often called "the Perl compiler", but is really a
+way for Perl programs to peek at its innards rather than create
+pre-compiled versions of your program. However. the B::Bytecode
+module can turn your script into a bytecode format that could be
+loaded later by the ByteLoader module and executed as a regular Perl
+script.
+
+There are also some commercial products that may work for
+you, although you have to buy a license for them.
+
+The Perl Dev Kit
+(http://www.activestate.com/Products/Perl_Dev_Kit/) from
+ActiveState can "Turn your Perl programs into ready-to-run
+executables for HP-UX, Linux, Solaris and Windows."
+
+Perl2Exe (http://www.indigostar.com/perl2exe.htm) is a
+command line program for converting perl scripts to
+executable files. It targets both Windows and unix
+platforms.
+
=head2 How can I compile Perl into Java?