Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re^2: Perl is a compiler cum interpreter?

by jimt (Chaplain)
on Feb 15, 2007 at 16:24 UTC ( #600233=note: print w/replies, xml ) Need Help??

in reply to Re: Perl is a compiler cum interpreter?
in thread Perl is a compiler cum interpreter?

I'd always thought it was compiled into a bytecode state, similar to java. Was I off in this?

One thing I've never understood is exactly why spitting out something in that intermediate step is apparently such a nuisance. If perl could plunk out the intermediate "compiled" bytecode (or optree or whatever it is), and then pick that up later, I think it'd be keen.

First off, it would skip re-building the blasted tree every time. Yes, yes, I know that it's fast, but if we don't need to do it, we should skip it. But mainly, it'd clarify that yes, perl does compile, and stop the people that claim it's just glorified shell scripting. I'd say perl is as much a compiled language as java is.

But, apparently, that's rather difficult to do, I guess. Can anybody explain why?

  • Comment on Re^2: Perl is a compiler cum interpreter?

Replies are listed 'Best First'.
Re^3: Perl is a compiler cum interpreter?
by diotalevi (Canon) on Feb 15, 2007 at 17:21 UTC

    As I said above, the compiled form is a bunch of C structs in memory with pointers to each other. You could just dump this directly to disk but then it'd only be meaningful on a perl compiled exactly the same way. To get something you could run on someone else's perl you'd need to normalize it too. People tried doing that with the B::Bytecode module but it turned out that it was faster to go from source to optrees than "bytecode" to optrees.

    So it's true that we could substitute parsing source for reconstituting optrees but parsing source is already so fast that there it isn't a win to "skip" it. If you want to try this out on your perl, write the results of perl -MO=Bytecode to disk and then check out the byteloader program. This has been removed in the latest dev versions of perl mostly because in addition to never actually being faster, it also never really worked.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re^3: Perl is a compiler cum interpreter?
by chromatic (Archbishop) on Feb 15, 2007 at 18:26 UTC
    First off, it would skip re-building the blasted tree every time.

    There's still the deserialization overhead, which is not cheap.

    Moving away from a tree representation to formal bytecode would help with that, but it would require such a change to the Perl 5 core that no one who knows how is likely to do it ever.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://600233]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2017-11-22 04:14 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (314 votes). Check out past polls.