Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Pre-compiled Perl?

by Laurent_R (Canon)
on Apr 03, 2017 at 16:44 UTC ( [id://1186849]=note: print w/replies, xml ) Need Help??


in reply to Pre-compiled Perl?

I was under the impression (probably miss guided) that Perl compiled scripts and stored the compiled code somewhere/somehow. If the modification time of the script hadn't changed it would subsequently not need to recompile every time the script was run.
No, that's wrong. The short answer is that a Perl script is recompiled each time it runs.

Replies are listed 'Best First'.
Re^2: Pre-compiled Perl?
by Anonymous Monk on Apr 04, 2017 at 16:10 UTC
    Sort of picking nits here, but AFAIK Perl5 is never really "compiled." It's executed directly from the parse tree. The parse tree is bulky and full of pointers, making it difficult to store and reload later. (Back in the day, there was a dump/undump mechanism that tried to do this, but it hasn't worked for a long time.)
      Yeah, I understand what you mean, but, to me, creating the parse tree is a form of compilation. The difference between compiled languages and interpreted languages was meaningful 20 or 25 years ago, but that distinction is very much blurred nowadays.

      Contrary to some other languages (e.g. shell, TCL, awk, makefile), Perl has clearly a compile phase and a run time phase. Whether the compile phase produces an op tree or an executable file has become to a large extent irrelevant in my view. But, yes, it's not really a compilation in the sense of what you do with a C program, you don't produce a binary executable program.

        > Contrary to some other languages (e.g. shell, TCL , awk,

        That's not up to date:

        Since version 8.4, Tcl has featured the ability to automatically translate scripts into bytecode where feasible

        from http://wiki.tcl.tk/38633

        It's interesting to note that one of the main arguments why TCL lost against competitors like Perl was the bad performance.

        Also what they call "bytecode" here seems to be high level opcode.

        That's all not very new stuff, I'm pretty sure many BASIC dialects in the 80s already "tokenized" the source in a "parsing" phase.

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

        I don't think we have any real disagreement except for terminology. A compiler translates one formal language to another. If you define the parse tree to be a language, your definition of "language" is loose enough that every data structure is a language, and that makes every program a compiler. Saying that a language is "compiled" in the old-school sense really means that it is "compiled to machine language," but as you say, the distinction is mostly unimportant these days.

        Contrary to some other languages (e.g. shell, TCL, awk, makefile), Perl has clearly a compile phase and a run time phase.
        All of those languages have to be parsed, so they clearly have a "parse phase." The thing about Perl is that it lets you execute Perl code during the parse. Off the top of my head, I can't think of any other language that lets you do that.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1186849]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-23 21:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found