Many moons ago Mike Cowlishaw added a feature to his REXX interpreter that the first time a script was run, it attached the compiled bytecode to the end of the source code. Under (the dos-like) OS/2, this was done but placing the bytecode after the ^Z char that delimited the end of the source module. The second and subsequent times the script was run, the interpreter looked for a signature string after the first ^Z in the file and if found, the bytecode was loaded and run without the need to re-interpret the source. The nice thing about the mechanism besides the quicker startup, was that as (dos) text editors stopped reading once they encountered the ^Z in the source, the byte code was automatically thrown away if the script was edited and saved, and the interpreter would recompile it next time the script was run. A nice simple mechanism of keeping the source and compiled versions in synch--and about the only good use I've encountered for the difference between text/binmode files.
It also made it possible to distribute the 'compiled' version without the source, by using a utility that removed everything between (the rexx equivalent of) the shebang line, and the ^Z. This meant that if the file was edited, the bytecode was discarded automatically, and there was nothing left except the shebang line.
Not that it was that hard to reverse engineer the bytecode, but you invariable ended up with something quite different to the original, and without comments or meaningful variable names meaning that it gave about the same degree of protection as distributing Java bytecode.
I wonder if a similar mechanism couldn't be used for perl scripts. When the script is read, if a paricular byte or series of bytes is encountered followed my a magic-style signature sequence, then Perl would just load the bytecode and ignore the source.
In turn, this would allow the construction and distribution of a light-weight Perl binary that didn't carry the weight of the source code parser and associated stuff, leaving just the bytecode interpreter.
This might restrict some language features, eval and the like, but (to me) that seems a small penalty. Then again, I rarely use eval anyway.
Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.
In reply to Re: Pre-position musing on "standalone executables"
by BrowserUk
in thread Pre-position musing on "standalone executables"
by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |