Compiler vs Interpreter vs JIT Compiler

 Interpreter :


Interpreter is a program which translates code into the intermediate code(Byte code) and then 

executes line by line at runtime .

That's why Speed is low.


* Initial Phase: Source code is executed directly.

* Runtime Monitoring: Code is interpreted line by line or statement by statement.

  * Execution Phase: Execution happens in real-time without a separate compilation step.

* Advantages: Flexibility, immediate feedback.



Compiler : 


Compiler converts code into machine code before program runs. 


* Initial Phase: Source code is compiled into machine code or intermediate form.

* Compilation Phase: Entire program is compiled before execution starts.

* Execution Phase: Executable or machine code is run directly by the CPU.

* Advantages: Fast execution, extensive optimizations.



JIT Compiler :


  * Initial Phase: Source code is compiled to bytecode.

* Runtime Monitoring: JIT compiler detects hot spots during runtime.

* Compilation Phase: Bytecode of hot spots is compiled into native machine code.

* Execution Phase: Native code is executed for hot spots, improving performance.

* Advantages: Combines the speed of native code execution with the flexibility of bytecode interpretation. 

Comments

Popular posts from this blog

Collection Framework of Java

What is DBMS ?