Compiler, Assembler, Interpreter for Competitive Exams

Download PDF of This Page (Size: 164K)

  • Compiler scans the entire program once and then converts it into machine language which can then be executed by computer’s processor. In short compiler translates the entire program in one go and then executes it. Interpreter on the other hand first converts high level language into an intermediate code and then executes it line by line.

  • The execution of program is faster in compiler than interpreter as in interpreter code is executed line by line.

  • Compiler generates error report after translation of entire code whereas in case of interpreter once an error is encountered it is notified and no further code is scanned.

  • Assembler is used for converting the code of low level language (assembly language) into machine level language.

  • We generally write a computer program using a high-level language.

  • A high-level language is one, which is understandable by us humans.

  • It contains words and phrases from the English (or other) language. But a computer does not understand high-level language.

  • It only understands program written in 0’s and 1’s in binary, called the machine code.

  • A program written in high-level language is called a source code.

Hence, a compiler or an interpreter is a program that converts program written in high-level language into machine code understood by the computer.

Compilers vs. Interpreters
Compilers vs. Interpreters

Interpreter

Compiler

Translates program one statement at a time.

Scans the entire program and translates it as a whole into machine code.

It takes less amount of time to analyze the source code but the overall execution time is slower.

It takes large amount of time to analyze the source code but the overall execution time is comparatively faster.

No Intermediate object code is generated, hence are memory efficient.

Generates Intermediate object code which further requires linking, hence requires more memory.

Continues translating the program until the first error is met, in which case it stops. Hence debugging ¡s easy

It generates the error message only after scanning the whole program. Hence debugging is comparatively hard.

Programming language like Python, Ruby use interpreters.

Programming language like C, C++ use compilers.

A computer program that translates a program statement by statement into machine languages is called a/an

(A) Compiler

(B) Simulator

(C) Translator

(D) Interpreter

Answer: (D)

Linker and Loader

As showing in fig is a Linker and Loader

Linker and Loader

As showing in fig is a Linker and Loader

  • Linker and Loader is the utility program that plays a major role in the execution of a program.

  • The Source code of a program passes through compiler, assembler, linker, loader in the respective order, before execution.

  • On the one hand, where the linker intakes the object codes generated by the assembler and combine them to generate the executable module.

  • On the other hands, the loader loads this executable module to the main memory for execution.