• NeatNit@discuss.tchncs.de
    link
    fedilink
    English
    arrow-up
    1
    ·
    12 hours ago

    For short, the term Interpreter I think is misunderstood here.

    Definitely, but I strongly think it’s you who is wrong here.

    No, it’s not compiled on the fly. With an interpreter, there is never a sequence of CPU instructions corresponding to the source code. All of the CPU instructions that run on the CPU are from the interpreter’s executable. The source code (or sometimes bytecode, which is still not CPU instructions) is treated as data. New machine code is never created.

    Compiling means creating new machine code that can run on the CPU. This happens in JIT. It doesn’t happen in an interpreter.

    • thingsiplay@lemmy.ml
      link
      fedilink
      English
      arrow-up
      1
      ·
      11 hours ago

      Compiler does not mean it will produce machine code, it just means the entire program is analyzed in its full and converted to something else (usually machine code, but it could be from JavaScript into TypeScript in example).

      Interpreter on the other hand takes source code and compiles one line after another in realtime. In terms of programming languages, depending on the environment it can produce machine code or call a function from another program. It can but does not have to produce machine code.

      There is also Bytecode and Just in Time compilation, which makes it even more confusing to explain.

      • NeatNit@discuss.tchncs.de
        link
        fedilink
        English
        arrow-up
        1
        ·
        10 hours ago

        I don’t know what to say other than your description doesn’t match the opening paragraphs on Wikipedia (which I linked earlier), which AFAIK match the common meaning of the terms. The existence of cross-compilation really muddies the water here, so to clarify, in this context when I’m talking about compilation I’m talking about compiling to machine code that can run natively on the hardware in question (CPU or GPU). Compiling to anything else (bytecode, different programming language, whatever) is irrelevant for the discussion IMO.

        And interpreters do not compile to machine code. If they do, it’s called JIT compilation, not interpretation.