http://www.perlmonks.org?node_id=489528


in reply to Doing a standalone executable (and even a binary!)

I'm not sure if this is a question; if so, it probably belongs in Seekers of Perl Wisdom. But even if you're just trying to start a discussion, you forgot to mention my favorite solution in this space: PAR. It allows you to package up scripts and modules in a package ala Java's jar format, but it also allows you to create a standalone executable.

It bundles your code up using the standard PAR format, then wraps it in an extractor and a perl executable. It may seem kind of wasteful, and does not prevent others from getting access to your original source code (it doesn't even try), but it certainly makes a convenient binary executable that you can run without much effort.

  • Comment on Re: Doing a standalone executable (and even a binary!)

Replies are listed 'Best First'.
Re^2: Doing a standalone executable (and even a binary!)
by xdg (Monsignor) on Sep 06, 2005 at 15:01 UTC

    It's not really clear if the OP has a question or is just musing. Sounded more like musing over what might be a good approach for standlone perl apps -- but there are really two separate issues that should be kept distinct:

    • Packaging up a perl script with an interpreter to run as a standalone
    • Storing the compiled perl bytecode so the source isn't recompiled each time

    PAR is only an answer to the first, I think. The OP seemed a bit more focused on the second. I'm not sure how much speed gain that really gives, though. It all comes down to the ratio of compile time versus run time. For user apps, I don't know that compile time matters so much.

    For the second, mod_perl and PersistentPerl are a couple of approaches used to address this with a persistent perl interpreter.

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

      How about creating a BINARY? How is the future of that?

        I'm not really sure what you mean by "binary".

        The real problem is that the whole notion of "compilation" and "executable" are really intertwined in an interpreted language like Perl. Some of what makes Perl easy to code comes from the ability to modify the executable code at runtime by compiling new code that is created during runtime.

        The best you're ever going to get to is bytecode that runs on the interpreter -- no different than Python or Java compiled bytecode files that run on their interpreters.

        B::Bytecode only takes you so far. As someone else pointed out -- you're probably not going to find what you want until Parrot gets further along.

        -xdg

        Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Re^2: Doing a standalone executable (and even a binary!)
by Ace128 (Hermit) on Sep 06, 2005 at 14:59 UTC
    Crap. Can someone move this to "Seekers of Perl Wisdom" then? :)