Compiler, interpreter, and Assembler


Compiler

A compiler is a software program that transforms high-level source code that is written by a developer in a high-level programming language into a low level object code (binary code) in machine language, which can be understood by the processor. The process of converting high-level programming into machine language is known as compilation.

It scans the entire program and translates it as a whole into machine code. Compiler takes large amount of time to analyze the source code but the overall execution time is comparatively faster. It generates the error message only after scanning the whole program. Hence debugging is comparatively hard. Programming language like C, C++ uses compilers.

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. Interpreter translates program one statement at a time. It takes less amount of time to analyze the source code but the overall execution time is slower. Programming language like Python, Ruby uses interpreters.

Assembler

An assembler is a program that takes basic computer instructions and converts them into a pattern of bits that the computer's processor can use to perform its basic operations. An assembler allows you to write instructions, in a relatively readable format, which the assembler then converts to the binary equivalent that the CPU understands.

The output of the assembler program is called the object code or object program relative to the input source program. The sequence of O's and 1's that constitute the object program is sometimes called machine code.


The difference between an interpreter and a compiler is given below:


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 is slower

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

No intermediate object code is generated ,hence are memory effective

Generates intermediate object code with further require which further required more memory

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

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

Programming language like python ,ruby,uses interpreters

Programming language like c,c++ uses compilers 






No comments:

Post a Comment

theengineerschoice01@gmail.com