Compiler vs Interpreter

CompilervsInterpreter


What is Compiler?

A compiler is a computer program that transforms code written in a high-level programming language into the machine code. It is a program which translates the human-readable code to a language a computer processor understands (binary 1 and 0 bits). The computer processes the machine code to perform the corresponding tasks.

A compiler should comply with the syntax rule of that programming language in which it is written. However, the compiler is only a program and cannot fix errors found in that program. So, if you make a mistake, you need to make changes in the syntax of your program. Otherwise, it will not compile.

What is Interpreter?

An interpreter is a computer program, which coverts each high-level program statement into the machine code. This includes source code, pre-compiled code, and scripts. Both compiler and interpreters do the same job which is converting higher level programming language to machine code. However, a compiler will convert the code into machine code (create an exe) before program run. Interpreters convert code into machine code when the program is run.

Role of Compiler

  • Compliers reads the source code, outputs executable code
  • Translates software written in a higher-level language into instructions that computer can understand. It converts the text that a programmer writes into a format the CPU can understand.
  • The process of compilation is relatively complicated. It spends a lot of time analyzing and processing the program.
  • The executable result is some form of machine-specific binary code.

Role of Interpreter

  • The interpreter converts the source code line-by-line during RUN Time.
  • Interpret completely translates a program written in a high-level language into machine level language.
  • Interpreter allows evaluation and modification of the program while it is executing.
  • Relatively less time spent for analyzing and processing the program
  • Program execution is relatively slow compared to compiler

Java is both Compiled and Interpreted.

To exploit relative advantages of compilers are interpreters some programming language like Java are both compiled and interpreted. The Java code itself is compiled into Object Code. At run time, the JVM interprets the Object code into machine code of the target computer.

Also Read: 
Differences Between Java vs .Net: Guide To Be Mastered

Conclusion

  • A compiler is a computer program which transforms code written in a high-level programming language into the machine code
  • An interpreter is a computer program, which coverts each high-level program statement into the machine code.
  • Compliers generates intermediate machine code that is saved to the computer as an exe
  • Interpreter never generates any intermediate machine code.
  • The interpreter converts the source code line-by-line during RUN Time.
  • The compiler needs a lot of time analyzing and processing the program.
  • Interpreter spends less time on analyzing and processing a program.

Leave a Reply

Your email address will not be published. Required fields are marked *