http://www.perlmonks.org?node_id=11127866


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

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.

Replies are listed 'Best First'.
Re^5: Performance penalties of in-Perl docn vs compiled CGIs. (updated x 2)
by dave_the_m (Monsignor) on Feb 03, 2021 at 18:44 UTC
    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.

      We had the discussion already in the past and I'm reluctant to reiterate it.

      And yes, it's semantics.

      Saying OP codes are not byte codes because the latter are more primitive "assembler like" and the former rather macros is also a matter of perspective.

      For instance it's far easier to deparse the original source for Java than C.

      But yes, granted, there are many languages targeting the JVM and only one for Perl's runtime, because the former is "simpler".

      But it should still be possible to generate a .plc from another language, at least in theory.

      And Java is still interpreted, because JIT ne AOT.

      Anyway

      The most crucial point if it comes to performance is rather static Vs dynamic typing, and nobody mentioned it yet.

      Optimizing X+Y is pretty complicated if one doesn't know if it's an integer, float, string or overloaded operation.

      Another dimension of shades of grey.

      ... And semantics.

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