Translators Flashcards Preview

Paper 2 - Computer Science > Translators > Flashcards

Flashcards in Translators Deck (16)
Loading flashcards...

What is Source Code?

Source code is the program code that is written by a programmer. Most source code programs are text files that can be created using a simple text editor.


When does source code need to be translated before it can be executed?

-When it's written in high level languages, source code needs to be translated into machine code.
-If they're already in machine code they don't need to be translated.
-The processor can only analyse machine code


What does machine architecture–dependent mean?

To run a program, the source code must be translated into object code according to the low-level features of the operating system and the instruction set has to be hardcoded into the computer's chipset


What are high level languages?
Give 2 examples

- Languages that are...
Python, Java


What are low level languages?
Give 2 examples

- Languages that sit close to the computer's instruction set
-Assembly language, Machine code


How is it determined which translator is used to translate a high level language?

It's determined by the particular implementation of a programming language, some provide only one option, some provide both


What does a compiler do?

It translates the code all at once but does not execute it


What are the advantages of using a compiler?

-Produces executable code in a form that cannot be read by a human or readily reverse-engineered, so the source code is more protected
- It translates all the code at once so it's faster
- Appropriate when the object code is going to be distributed or sold


What does an interpreter do?

Interpreters translate and execute each line of source code one by one


What are the advantages of using an interpreter?

-can test the code and to quickly identify and fix errors.
-Interpreters are useful in the development stage of a program as they don't need to recompile every time an error is discovered


What does an assembler do?

Assemblers translate assembly code programs into machine code.


What is Bytecode?

Bytecode is source code that has been compiled into low-level code designed to be run on a virtual machine so it speeds up the translation process.


2 advantages of using Bytecode

- The source code is executable on a wide range of platforms as its platform independent
- Provides an extra level of protection as a separate bytecode interpreter is used.


How does an assembler translate code from a high level into a low level?

It translates the source code (the input) into the equivalent 1's and 0's in machine code, producing object code.


How does a compiler translate code from a high level into a low level?

It scans over the source code several times performing checks and building up tables of information to produce the final object code


How does an interpreter translate code from a high level into a low level?

-It uses subroutines that carry out high level instructions
-It analyses each line of source code for syntax errors, if there are none it calls the appropriate subroutine to execute the command.