Module 4 Chapter 4 Programming Language Translators Flashcards Preview

A-Level Computer Science AQA > Module 4 Chapter 4 Programming Language Translators > Flashcards

Flashcards in Module 4 Chapter 4 Programming Language Translators Deck (14)
Loading flashcards...

Why does code written in anything other than machine code need to be translated before it can be run?

Because processors can only "understand" binary.


What would be used to translate assembly language into machine code?

An assembler.


What problems could arise when running assembly language on a machine other than the one it was written on?

The assemblers used by the two machines may be different (have a different instruction set) and could therefore translate the instructions incorrectly.
For example, one processor may represent LDA as 0000 whereas another may represent it as 1000 causing the translated code to be different.


What is an assembler?

A program that converts a program in assembly language (source code) into machine code (object code).


What is source code?

The input for a translator, written in assembly language or a high-level programming language.


What is object code?

The output of a translator, written in machine code.


What is a compiler?

A compiler is a program that translates a high-level language such as Java or C# into machine code. The code written by the programmer, the source code, is input as data to the compiler, which scans through it several times, each time performing different checks and building up tables of information needed to produce the final object code. Different hardware platforms will require different compilers, since the resulting object code will be hardware-specific. For example, Windows and Intel microprocessors comprise one platform, Apple and PowerPC processors another, so separate compilers are required for each. The object code can then be saved and run whenever needed without the presence of the compiler, making it faster to launch.


What is an interpreter?

An interpreter is a program that translates a high-level language such as Python into machine code. Once a programmer has written and saved a program ad instructs the computer to run it, the interpreter looks at each line of the source program, analyses it and (if it contains no syntax errors) translates it into machine code and runs it. The interpreter may scan through the entire code for certain basic errors such as a missing bracket before running any of the code. This is the case in many languages such as Python.


What name is given to code produced by a combination of compiling and interpreting?



What is used to run bytecode?

A bytecode interpreter.


What are the main advantages of using byte code?

- You can achieve platform independence. The bytecode can be interpreted on different types of machine architecture.
- It may act as an extra layer of security between an unknown program and your computer as the bytecode interpreter will guard against malicious software.
- It is possible to convert from one programming language to another. For instance, Python can be compiled into Java bytecode and run by the Java interpreter.


Give four advantages of using a compiler over an interpreter.

- The object code can be saved on disk and run whenever required without the need to recompile. However, if an error is discovered in the program, the whole program has to be recompiled.
- The object code executes faster than interpreted code.
- The object code produced by a compiler can be distributed or executed without having to have the compiler present.
- The object code is more secure, as it cannot be read without a great deal of reverse engineering.


Give two advantages of using an interpreter over a compiler.

- It is useful for program development as there is no need for lengthy recompilation each time an error is discovered.
- It is easier to partially test and debug programs.


Give one disadvantage of using an interpreter over a compiler.

The program may run slower than a compiled program, because each statement has to be translated into machine code each time it is encountered. So if a loop of ten statements is performed twenty times, all ten statements are interpreted twenty times.

Decks in A-Level Computer Science AQA Class (36):