Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^2: Performance penalties of in-Perl docn vs compiled CGIs.

by LanX (Saint)
on Feb 03, 2021 at 15:05 UTC ( [id://11127858]=note: print w/replies, xml ) Need Help??


in reply to Re: Performance penalties of in-Perl docn vs compiled CGIs.
in thread Performance penalties of in-Perl docn vs compiled CGIs.

If Perl is interpreted, so is Java.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

  • Comment on Re^2: Performance penalties of in-Perl docn vs compiled CGIs.

Replies are listed 'Best First'.
Re^3: Performance penalties of in-Perl docn vs compiled CGIs.
by dave_the_m (Monsignor) on Feb 03, 2021 at 15:32 UTC
    The main thing that B::C does is output the start-up state of the perl interpreter (post-compilation but before execution) as a bunch of C structs which can be compiled into an executable. This improves the start-up time of the code, but has little effect on the run-time performance - which is still the perl interpreter calling out to a C-level pp_foo() C function for each op in the perl OP tree (the OP tree now being a static structure hard-coded into the executable). There is no JIT compilation to machine code in the Java sense (unless something has changed recently in B::C).

    So really there aren't any perl compilers - in the sense of something that at some point (build time or run time) converts perl code into machine code for fast execution.

    Dave.

      Yes Java has JIT, but this was not always so.

      Both languages have a "virtual machine" with OP-codes/Bytecode which is/can be interpreted.

      My point is, the black and white distinctions between compiler and interpreter are from the <80s and don't match the current shades of grey anymore.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

      update

      Please correct me, but IIRC is JIT only attempting to compile a code path if past interpretation proved to be inefficient. Hence "interpretation" is still the default.

      update

      from WP: Just-in-time_compilation

      A system implementing a JIT compiler typically continuously analyses the code being executed and identifies parts of the code where the speedup gained from compilation or recompilation would outweigh the overhead of compiling that code.

      JIT compilation is a combination of the two traditional approaches to translation to machine code – ahead-of-time compilation (AOT), and interpretation – and combines some advantages and drawbacks of both.

        A difference is that perl doesn't haven anything resembling a virtual machine or bytecode. Bytecode typically maps fairly easily to equivalent machine code instructions; in principle you could envisage building a CPU that directly executes Java bytecode, in exactly the same sense that we currently have CPUs which can directly execute X86_64 machine code. Perl just has heaps of complex data structures - OP trees, SV trees, regexes etc - none of which maps to a linear set of bytes representing an idealised CPU.

        At one point there was perl "bytecode" - but all it was was a way of serialising the contents of all those data structures to a file and then reading them back. It was said to be slower than just compiling.

        But this is all a bit nit-picky and toying with semantics. The main take-home point is that when people look for "a perl compiler", what they will find likely won't match their expectations in terms of what it does and what benefits it provides. Hence why I usually feel the urge to disabuse OPs of the notion in such threads.

        Dave.

Re^3: Performance penalties of in-Perl docn vs compiled CGIs.
by ikegami (Patriarch) on Feb 05, 2021 at 00:07 UTC
      > Is Perl a compiled or an interpreted programming language?

      Yep, the answer is both... this distinction is from the 70s and doesn't apply to many newer languages.

      You mentioned a Perl to LLVM translation in SO, where can I find out more about this project?

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        That was 10 year ago, and I haven't heard anything since. Probably mentioned on the p5p mailing list?

        Seeking work! You can reach me at ikegami@adaelis.com

      I like one of the comments below your linked post which points out what's really important in this distinction: interpreted language can be extended ad-hoc, eg. eval. That's a lot of flexibility.

        What if we bundled the executable of a "compiler language" like C or Go with a compiler?

        Why shouldn't it be possible to do that?

        And "eval"-ing would mean to run a make process leading to dynamically linked and executed code?

        According to you this would define an "interpreter", right? :)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

Re^3: Performance penalties of in-Perl docn vs compiled CGIs.
by Anonymous Monk on Feb 03, 2021 at 19:42 UTC
    Yes. In the original Apple ][, Steve Wozniak used an interpreter which he called "SWEET16," to very great effect. Precious memory-bytes were saved, and "Integer BASIC" ran as well as it could have.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found