3.8 - Program Construction

Cards (21)

  • Translators
    Converts high level and low level languages into machine code that can be executed by the CPU
  • An assembler converts assembly code into machine code
  • Assembled code runs faster than compiled code as one assembly instruction is converted into a single machine code instruction
  • Assembly code is a low level language that uses mnemonics to represent instructions, making code more difficult to develop
  • Assembly language gives a programmer greater control over memory and CPU usage
  • A compiler converts a high level language into executable machine code
  • Compilers convert all code at once which can be slow. However, an executable file is produced which runs faster than an interpreted program as all code has already been converted to machine code
  • Compiled programs can help protect intellectual property as the source code cannot be viewed
  • Compiled code must be recompiled if the source code is changed or if the target platform changes
  • Interpreted languages are easier to debug because errors only affect one line of code rather than whole sections
  • Interpreters converts high level languages into machine code line by line
  • Interpreters allow code to be executed on the fly so a program can be run at any time for debugging
  • Interpreters do not produce an executable file so must be interpreted again each time it is run, making it slower and more inefficient than compiled code
  • Interpreted programs stop when errors occur, highlighting the code that failed
  • Interpreted programs are easier to debug as only single errors are shown while compiled programs may display many errors at the same time
  • Interpreted programs are open source, so anyone can view and copy the code
  • Interpreted programs are more portable than compiled programs as they do not require a target platform
  • Compilation Process
    1. Lexical Analysis
    2. Syntax Analysis
    3. Semantic Analysis
    4. Code Generation
    5. Optimisation
  • A syntax error is where the source code does not follow the expected syntax of the language
  • Linking errors are where a subroutine is missing from the libraries that that the program is drawing on
  • Run-Time Errors are where elements have been programmed incorrectly, causing the program to crash