Programming languages

Cards (9)

  • Machine code
    • Binary representation of instructions
    • Formatted so CPU can decode and execute
    • Have an operation code instruction and address or data to use
  • Low level languages
    • Written in Assembly code
    • Translated by an assembler into machine code
    • Code is fast to execute
    • Memory efficient
    • Code is harder to write and understand
    • The programmer works with memory directly
    • The code works on one type of processor only
    • One instruction translated into one machine code instruction
    • Used to instruct the hardware directly (embedded systems/device drivers)
  • High level languages
    • Source code is written in languages (Python, C++, Java)
    • Translated by a compiler or interpreter into machine code
    • Writing computer programs is easier - uses commands similar to English
    • One source code instruction translates into many machine code instructions
    • Code will run on different types of processors
    • Programmer has lots of data structures to use
    • Code is quicker and easier to understand and write
    • Less memory efficient
    • Code can be slower to execute if not optimised
  • Compilers
    • Translates source code from high-level languages into object code, then machine code - to be processed by CPU
    • The entire program is translated into machine code before it is run
  • Compiler advantages
    • No need for translation software at run-time
    • speed of execution is faster
    • code is usually optimised
    • original source code is kept secret
  • Compiler disadvantages
    • source code is easier to write in a high-level language, but the program will not run with syntax errors - difficult to write the code
    • code needs to be recompiled when the code is changed
    • designed for a specific type of processor
  • Interpreter
    • Translates source code from high level languages into machine code - to be processed by the CPU
    • the program is translated line by line as the program is running
  • Interpreter advantages
    • easy to write source code - program will always run, stopping when a syntax error is found
    • code does not need to be recompiled when the code is changed - easy to try out commands when the program has paused after finding an error
    • interpreted languages are easy for beginner programmers to learn to write code
  • Interpreter disadvantages
    • translation software is needed at run-time
    • speed of execution is slower
    • code is not optimised
    • source code is needed