0% found this document useful (0 votes)
20 views

9. Language Translator

Uploaded by

mahfujsdp35
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

9. Language Translator

Uploaded by

mahfujsdp35
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Computer Language Translator

Computer are electronic devices can only understand machine level binary
code (0/1 or on/off) and it is very difficult to understand and write a program
in machine language so, developers use human-understandable high level
and assembly instructions. So, to solve this gap, a translator is used which
is used to convert high-level instructions to machine-level instruction (0 and
1).

The
program
understandable
of thetranslator
code.
writtenis
low-level
in ahigh-level
programming
machine
or assembly
language
language
language
without
processor
losing
program
that
the translates
to
functionality
machine- a

Why Computer Language Translator?

The computer understands only machine code. It does not understand any
low, assembly, and high-level language. There must be a program to
convert the source into object code to make it understood by your
computer. This is the task of the language translator. The programmer
writes and then converts the source code into a readable machine format
(object code)

What is Translators? Different type of


translators
A program written in high-level language is called as source code. To convert the
source code into machine code, translators are needed.
A translator takes a program written in source language as input and converts it into
a program in target language as output.
It also detects and reports the error during translation.

Roles of translator are:


• Translating the high-level language program input into an equivalent machine
language program.
• Providing diagnostic messages wherever the programmer violates specification of
the high-level language program.
Different type of translators

The different types of translator are as follows:


Compiler

Compiler is a translator which is used to convert programs in high-level language to


low-level language. It translates the entire program and also reports the errors in
source program encountered during the translation.
Interpreter

Interpreter is a translator which is used to convert programs in high-level language to


low-level language. Interpreter translates line by line and reports the error once it
encountered during the translation process.
It directly executes the operations specified in the source program when the input is
given by the user.
It gives better error diagnostics than a compiler.

Differences between compiler and interpreter

SI. Compiler Interpreter


No

1 Performs the translation of a program Performs statement by statement


as a whole. translation.

2 Execution is faster. Execution is slower.

3 Requires more memory as linking is Memory usage is efficient as no


needed for the generated intermediate intermediate object code is
object code. generated.

4 Debugging is hard as the error It stops translation when the first


messages are generated after scanning error is met. Hence, debugging is
the entire program only. easy.

5 Programming languages like C, C++ Programming languages like Python,


uses compilers. BASIC, and Ruby uses interpreters.

Assembler
Assembler is a translator which is used to translate the assembly language code into
machine language code.

You might also like