Re: Compiling Perl to Bytecode (Was: Fruit basket program in Boo)

  • From: Veli-Pekka Tätilä <vtatila@xxxxxxxxxxxxxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Mon, 22 Oct 2007 22:19:04 +0300

HI Octavian,
I haven't tried B::Bytecode with any complex programs. However, I
suppose strict might be a problem. It is not a normal module, it is a
compiler pragma i.e. you cannot require strict, for instance. Howabout
trying to compile larger modules with strict and warnings temporarily
disabled. Until we know of a sure wai to get them included properly in
the byte code.

Another point the free to try perl2exe program works wonderfully, if you
stick to using only one use statement per line. But that one doesn't
compile to Perl byte code, it packs the code files inside an exe and
then extracts normal Perl code in a temp dir, running the whole
interpreter from the exe. That's how most such apps work for the dynamic
langs.

You can get the app at:

http://www.indigostar.com/perl2exe.htm

I've been succesfully using it for many projects.

There are already some implementations of Perl 6 but it is far from
ready. IN the meantime you can read columns like this:

http://www.oreillynet.com/onlamp/blog/2007/09/yet_another_perl_6_operator_th_1.html

-- 
With kind regards Veli-Pekka Tätilä (vtatila@xxxxxxxxxxxxxxxxxxxx)
Accessibility, game music, synthesizers and programming:
http://www.student.oulu.fi/~vtatila

Octavian Rasnita wrote:
> 
> Yes I know that module, but... have you tried it?
> 
> I've tried it and for some more complex programs than a simple "Hello world"
> it doesn't work.
> 
> It works as good as the program perlcc which is included in perl and which
> should be able to compile a perl program into an executable.
> (unfortunately)
> 
> I hope perl 6 will be ready sooner than 10 years from now on. :-)
> 
> Octavian
> 
> ----- Original Message -----
> From: "Veli-Pekka Tätilä" <vtatila@xxxxxxxxxxxxxxxxxxxx>
> To: <programmingblind@xxxxxxxxxxxxx>
> Sent: Monday, October 22, 2007 8:37 PM
> Subject: Re: Compiling Perl to Bytecode (Was: Fruit basket program in Boo)
> 
> > Hi Octavian.
> > Actually, Perl can compile to byte code it is just that not many people
> > know it.
> >
> > perldoc B::Bytecode
> >
> > says:
> >
> >    Compiles a Perl script into a bytecode format that could be loaded
> > later
> >    by the ByteLoader module and executed as a regular Perl script.
> >
> > See the rest of the manual page for an example and some switches.
> >
> > Similarly
> >
> > perldoc -f require hints:
> >
> >            <snip> Before "require" looks
> >            for a ".pm" extension, it will first look for a filename
> > with a
> >            ".pmc" extension. A file with this extension is assumed to
> > be
> >            Perl bytecode generated by B::Bytecode. If this file is
> > found,
> >            and its modification time is newer than a coinciding ".pm"
> >            non-compiled file, it will be loaded in place of that
> >            non-compiled file ending in a ".pm" extension.
> >
> > This applies to use as well:
> >
> > perldoc -f use
> >
> >            It is exactly equivalent to
> >
> >                BEGIN { require Module; import Module LIST; }
> >
> >            except that Module *must* be a bareword.
> >
> > I'm sure you'll be able to find some examples on the inet, too. The
> > bytecode support is still a bit experimental and there are certain
> > special cases and switches you should read about in the B::Bytecode man
> > page. Note that the
> >
> > perl -MO
> >
> > syntax means loads a special module called O which loads the Perl
> > compiler backends under the B::namespace. YOu can even disassemble Perl
> > code annd often the B::Deparse module is a great help in interpreting
> > how Perl actually executed your expression. See its man page, too.
__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: