Interpreter vs Compiler vs JIT Compiler

Поділитися
Вставка
  • Опубліковано 12 січ 2025

КОМЕНТАРІ • 22

  • @TechPrepYT
    @TechPrepYT  7 місяців тому +1

    Checkout 👉 techprep.app/yt 🔥

  • @Israel220500
    @Israel220500 6 місяців тому +23

    Great that you explicitly said that interpreters actually convert to an intermediate representation before executing. I've seen programmers thinking interpreters actually execute the source code line by line (I guess this probably comes from some old book or course) and get shocked when I show them "import dis" in Python.

    • @Jay-LT_513
      @Jay-LT_513 6 місяців тому +1

      Newb here, please explain this to me in simple terms. I'm not the best with English but I am pretty good at learning.
      Thank you kindly

    • @Israel220500
      @Israel220500 6 місяців тому +13

      @@Jay-LT_513 Computers can' t understand directly the code that we write with english words, it has to be "translated" to machine code (which is just 0s and 1s). There are two main strategies to do this: 1 - Compilers, which are common for languages like C and Rust, where the code you write is converted to machine code ahead of time and produces an executable (think of an exe file on windows).
      2 - Intepreters, in this case there's another program that always runs along with the program you wrote and is responsible for translating your instructions into machine code. But it would be very inefficient to translate code from languages like Python and JavaScript line by line, so instead, an intermediate representation that is easier to convert into machine code is generated first.

    • @gesuchter
      @gesuchter 5 місяців тому

      🇵🇸

    • @Jay-LT_513
      @Jay-LT_513 5 місяців тому

      @Israel220500 Thank you friend

    • @remains2246
      @remains2246 4 місяці тому +1

      i dont think its correct to say interpreters convert to bytecode. thats a compiler

  • @pendergastj
    @pendergastj 2 місяці тому +1

    Also, JIT compilers can create more optimized code based on the context of the program and memory.

  • @МаксимФомин-у4ф
    @МаксимФомин-у4ф 4 місяці тому +1

    Need to say that the goal of converting source code to low-level machine code is for compilers. In case of interpreted languages the resulted machine code (byte code) will be executed by a virtual machine (analogue of a real CPU). This is why Java has separated compiler and JVM (an interpreter of byte code).

  • @nathanphan3042
    @nathanphan3042 Місяць тому

    So, java is interpreter because It compiles to intermediate code particularly bytecode

  • @MortonMcCastle
    @MortonMcCastle 6 місяців тому +5

    That's neat!

  • @pietropalandrani8556
    @pietropalandrani8556 7 місяців тому +13

    Better explanation than the one gave by my uni professor 🫡

  • @renatorucov8603
    @renatorucov8603 4 місяці тому

    I don't understand why mistakes are made in these definitions all the time
    ----A compiler, by definition, is not something that can only translate code into machine code.
    A compiler (c#-Rosyln ,java-Javac ,JIT compiler etc )is a software tool that takes source code and translates it all at once into either intermediate code (like IL or bytecode) or directly into machine code. Compilers perform this conversion before running the code. When intermediate code (such as IL) is generated, it is typically further compiled into machine code at runtime (e.g., via JIT compilation).
    and I think your definition of interpreter is not correct either.
    but thank's anyway