Language Processors-Assembler-Compiler-Interpreter
Language Processors-Assembler-Compiler-Interpreter
Language Processors-Assembler-Compiler-Interpreter
1.Compiler :
The language processor that reads the complete source program written in high-level
language as a whole in one go and translates it into an equivalent program in machine
language is called a Compiler. Example: C, C++, C#, Java.
In a compiler, the source code is translated to object code successfully if it is free of
errors. The compiler specifies the errors at the end of the compilation with line numbers
when there are any errors in the source code. The errors must be removed before the
compiler can successfully recompile the source code again
2.Assembler :
The Assembler is used to translate the program written in Assembly language into
machine code. The source program is an input of an assembler that contains assembly
language instructions. The output generated by the assembler is the object code or
machine code understandable by the computer. Assembler is basically the 1st interface
that is able to communicate humans with the machine. We need an Assembler to fill the
gap between human and machine so that they can communicate with each other. code
written in assembly language is some sort of mnemonics(instructions) like ADD, MUL,
MUX, SUB, DIV, MOV and so on. and the assembler is basically able to convert these
mnemonics in Binary code. Here, these mnemonics also depend upon the architecture
of the machine.
For example, the architecture of intel 8085 and intel 8086 are different.
3.Interpreter :
The translation of a single statement of the source program into machine code is done
by a language processor and executes immediately before moving on to the next line is
called an interpreter. If there is an error in the statement, the interpreter terminates its
translating process at that statement and displays an error message. The interpreter
moves on to the next line for execution only after the removal of the error. An
Interpreter directly executes instructions written in a programming or scripting language
without previously converting them to an object code or machine code.
Example: Perl, Python and Matlab.
COMPILER INTERPRETER
1 A compiler is a program that An interpreter takes a source
converts the entire source code of a program and runs it line by line,
programming language into translating each line as it comes to it
executable machine code for a
CPU.
2 The compiler takes a large amount of An interpreter takes less amount of
time to analyze the entire source time to analyze the source code but
code but the overall execution time the overall execution time of the
of the program is comparatively program is slower.
faster.
3 The compiler generates the error Its Debugging is easier as it
message only after scanning the continues translating the program
whole program, so debugging is until the error is met.
comparatively hard as the error can
be present anywhere in the
program.
4 The compiler requires a lot of It requires less memory than a
memory for generating object codes. compiler because no object code is
generated.
5 Generates intermediate object code. No intermediate object code is
generated.
6 For Security purpose compiler is The interpreter is a little vulnerable
more useful. in case of security.
7 Examples: C, C++, Java Examples: Python, Perl, JavaScript,
Ruby