Compiler vs. Interpreter

  • comments 0
  • views26,700

Difference between Compiler and Interpreter

For the layman, the programming world is a vast cornucopia of indecipherable terms and processes, many of which are hidden under the slick and glossy veneer of a graphical user interface. Take for instance compilers and interpreters, the existence of which most computer users are blissfully unaware. Most people who use a computer don’t even know the first thing about these programs, although it would be beneficial to possess at least a cursory knowledge of them. Here then is a look at their more salient aspects.

Compiler
Interpreter

Definition

Compilers are essentially programs that work as a translator for other programs known as source code. Source code is typically written in high level programming language, and compilers translate this into object code. Compilers are so named because they collect and organizing every single instruction in the source code.An interpreter for its part translates high-level instructions into a simpler form and then executes the resulting code. Interpreters function differently from compilers in that they analyze and execute each line of code in sequence without scanning the entire program beforehand. This allows them to execute a program instantly, as opposed to compilers that can take a long time to parse the data.

Function

Compilers work with high-level languages, some of which are Java and C. Programmers generally write the code one line at a time with an editor and the resulting file is then run using a compiler specific to the particular language.An interpreter on the other hand translates the code line by line and executes each translated line immediately. Although interpreters do generate binary code, this code isn't compiled into a specific program as much as it is interpreted every single time the program executes. Some of the more familiar interpreted programs are BASIC and Visual Basic.

Speed And Efficiency

Programs that result from a compiler are generally executed faster than programs that result from an interpreter. On the other hand, one notable advantage of interpreters is that they generally bypass the compilation stage of the process, which can take a lot of time for long programs. Since interpreters are able to execute high-level programs quickly, programmers often use them during the development stage when minor alterations to the program have to be implemented and tested quickly.Compilers for their part are used to translate source code into the particular object code required by specific computers, and as such, they come in specific "flavors" for each platform or operating system.

Summary

Compiler

  • Translates high-level instructions into machine language
  • Usually takes a long time to analyze and process a program
  • Results in an executable program that is a machine-specific form of binary code
  • Prepares the code which is "interpreted" by the computer hardware
  • Results in a faster running program
  • Runs on any computer

Interpreter

  • Translates high-level instructions into intermediate code, and then executes the program
  • Is comparatively faster at program analysis and processing
  • Results in a form of intermediate code that is "interpreted" by another program
  • Results in comparatively slow executing programs
  • Runs only on computers with an interpreter installed

Which one is more critical?
  • Compiler
  • Interpreter
 
 

comments Comments

Post a Comment
  • Name*
  • Email*