2.5.1

Cards (9)

  • High-level languages:
    • e.g. Python or C++
    • Easy for humans to write, but computers need to translate it before they can read and run it
  • Low-level languages:
    • Machine code (binary) and assembly language (uses mnemonics to replace binary codes, such as STA to store a value in a memory address)
    • Hard for humans to write and read but easier for a computer to run
  • High-level languages:
    Advantages:
    • Quicker and easier to understand and write
    • The same code will work for many different machines and processors (machine independent)
    • Data can be stored in different ways (e.g. lists and arrays)
    Disadvantages:
    • Less memory efficient
    • Slower
    • Must be translated before a computer can understand it
  • Low-level languages:
    Advantages:
    • Machine code executes very fast as it doesn't have to be translated
    • Assembly code also executes very fast, but not as fast as machine code
    • Assembly code is easier and faster to write and understand than machine code
    • Efficient use of memory
    Disadvantages:
    • Processor specific
    • Hard and time consuming to write and understand
    • Assembly code has to be translated into machine code by an assembler before it can be executed which makes it slower than machine code
  • Translators:
    • Compiler - translates high-level languages into machine code
    • Interpreter -translates high-level languages into machine code
    • Assembler - translates assembly language into machine code
  • Difference between compilers and interpreters:
    • Compilers translates the whole program directly into machine code and creates one executable file
    • Interpreters translate each line of code and executes it separately, but doesn't create an executable file
  • Difference between compilers and interpreters:
    • A compiler is only needed once to create the executable file
    • A interpreter is needed every time you want to run the program
  • Difference between compilers and interpreters:
    • A compiler returns a list of errors for the entire program once compiling is complete. The program will not run with errors and it is harder to find errors.
    • The interpreter will return the first error it finds and then stop - this is more useful for debugging
  • Difference between compilers and interpreters:
    • Once compiled the program runs quickly, but compiling can take a long time.
    • When interpreting programs will run slower because the code is being translated as the program is running
    • When interpreting code doesn't need to be recompiled when the source code is changed