成人快手

Computer structureTranslators

The CPU handles instructions. Translators in the form of an interpreter or compiler translate code into binary. Buses are used to allow data to move between RAM and the Processor (ALU, Control Unit and Registers).

Part of Computing ScienceComputer systems

Translators

High-level languages such as Python, LiveCode, Reference Language and Visual Basic all require translators to translate code created by programmers into binary.

The processor cannot understand the English-like instructions used by programmers when creating code in high level languages. Translators ensure the code is executable (in binary form for the processor to handle).

High level programming language translated into binary.

Translator software usually comes in the form of either a compiler or an interpreter.

Compiler

Compilers translate source code into object code. Object code is held in a new file and does not require use of translator software to run.

  • translates source code into 'object code'
  • compiler is only held in RAM for the time that it takes to translate source code into object code
  • translates lines one after the other but does not execute a line immediately after translation
  • once created, object code can run independently of development environment and translator software
  • if the object code file contains errors, the program will crash or cause unexpected output. Programmers must revisit source code, identify and correct errors and recompile

Interpreter

Interpreters translate source code directly into machine code. The translator runs throughout this translation and execution process.

  • each line of source code is translated to machine code one at a time
  • each line of code is executed as soon as it is translated
  • interpreter software is present in main memory during each execution of program and execution of every line
  • interpreter will not translate the next line if it encounters an error
  • execution will stop immediately if the interpreter translates a line of source code that results in an error
  • user notified of error immediately
  • interpreter a useful tool to assist programmers as they attempt to identify and rectify errors
  • cannot determine the actual error but can indicate the line that was not translated into executable machine code