Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Pre-compiled Perl?

by Laurent_R (Canon)
on Apr 04, 2017 at 23:07 UTC ( [id://1187050]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Pre-compiled Perl?
in thread Pre-compiled Perl?

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.

Replies are listed 'Best First'.
Re^4: Pre-compiled Perl?
by LanX (Saint) on Apr 04, 2017 at 23:47 UTC
    > 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!

      > many BASIC dialects in the 80s already "tokenized" the source in a "parsing" phase.

      On Commodore 116/16 and 64, you could even program directly in the tokens. ? was print , most others were just abbreviations like fO instead of for or oP instead of open . And when you byte-dumped the memory containing the program, it contained these instead of all the commands.

      ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
        WOW!

        You know Commodore Basic was my first programming language° (on a CBM4000), and it was very surprising to find out later that other languages/Basic dialects didn't support ? for print.

        You somehow just solved a decades old miracle for me ... =D

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

        PS: or I simply just forgot in the meantime ;-)

        footnotes

        °) though I actually had GFA_BASIC in mind when talking about tokenization

      Interesting ++. I did not know that, thank you for the information.
Re^4: Pre-compiled Perl?
by Anonymous Monk on Apr 05, 2017 at 00:50 UTC

    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.
      > The thing about Perl is that it lets you execute Perl code during the parse.

      What do you mean?

      Macros are executed during the parse and LISP is one of the two oldest higher order languages and often copied.

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

        What do you mean?

        I guess it is the fact that files loaded via use are compiled and executed whilst parsing the loading file.

        perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
        Macros are executed during the parse and LISP is one of the two oldest higher order languages and often copied.
        Hm. Obviously I haven't thought my statement through all the way. LISP can be completely parsed without executing any code; Perl can't.

Log In?
Username:
Password:

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

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

    No recent polls found