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 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.
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).
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
Checkout 👉 techprep.app/yt 🔥
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.
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
@@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.
🇵🇸
@Israel220500 Thank you friend
i dont think its correct to say interpreters convert to bytecode. thats a compiler
Also, JIT compilers can create more optimized code based on the context of the program and memory.
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).
So, java is interpreter because It compiles to intermediate code particularly bytecode
That's neat!
Thanks!
Better explanation than the one gave by my uni professor 🫡
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