Translators
Translators
Translators
Computer Science
Class 9th –Worksheet-2
1st June, 2021
Name: ______________________ Date: ______________
Q.1 Explain what a compiler does and what an interpreter does. In your explanation
include a description of the differences between them.
Compiler: A compiler is a type of translator that translates a high level language code into
machine code and creates an executable file for it. A compiler translates everything at once
and does not present any errors during compilation, rather at the end of compilation. A
compiler is also required to create programs without revealing the source code. It is
different from interpreters as you only have to compile a program once.
Interpreter: An interpreter is a type of translator that translates a high level language code
into machine code to be ran. An interpreter translates line by line and presents any errors
during translation, rather than the end of translation. An interpreter is not suitable for
translating distributive programs as it reveals the source code. It is different from compilers
as the program needs to be translated every time the program needs to be run, making it
inefficient for users, however better for development.
Q.2 Choose which type of translator you would use to develop a program written in a high-
level programming language. Give three reasons to support your choice.
Q.5 Many programmers write computer programs in high-level languages. The programs
need to be translated into machine code to be read by the computer. State two types of
translator that can be used.
Translator 1. Compiler
Translator 2. Translator
Q.6 Salman is writing a program using a high-level language. The program will be published
and sold for profit. Salman uses an interpreter when creating the computer program.
Q.7 Zaib has written the program and started compiling it.
Benefit 1. Compilers can create an executable file after the compilation which can be easily
distributed and the source code of the program is not revealed
Benefit 2. They translate the program all at once and not line by line which is better for
performance and also does not slow down when executing loops.
• Akbar is preparing a program written in a high-level language for sale. State, with reasons,
which type of translator each programmer should use. Each programmer should be using a
different type of translator.
Salma: Salma can use an assembler to assemble the assembly as it is the only type of
translator that is available to translate low level language. It should be fairly efficient and
faster as compared to other translators as it associates each command with a similar
command on the processor.
Zainab: Zainab should use an interpreter to develop a program written in a high level
programming language as it allows errors to be logged easily during translation, improving
time management and productivity. As a program is being developed, there is a need of
debugging and correction every once in a while and it would be tedious to compile it into
an executable file every time something needs to be tested. Furthermore, the source code
is visible to us and we are not distributing the program as it is not for sale, therefore we
also do not need to use compilers.
Akbar: A compiler creates an executable file for a program. A compiler is also required to
create programs without revealing the source code, and just the machine code it is
translated into. It has to be just compiled once and later the program can be used by
executable files, which are a lot faster to run than translating the program again.
Executable file it produces is also very easy to distribute.
Q.9 Five statements about interpreters and compilers are shown in the table below.
✓
✓
✓
✓
✓
Q.10 Complete the following by writing either compiler, interpreter or assembler in the
spaces provided.