Languages and Translators Flashcards
What are the two categories of languages? And provide an example for each
Low-level and high-level languages.
Machine code and python
Define machine code, assembly language and a high-level.
Machine code: Code compiled to binary or hexadecimal.
Assembly language: Low level symbolic code using mnemonics.
High-level: Programs written using English-like words and platform independent
What is the difference between imperative and declarative?
Imperative: Is how to achieve the goal
Declarative: States the goal
Difference between interpreter and a compiler
Interpreter: Translates code line-by-line
Compiler: Translates the whole code at once.
Pros and cons of a interpreter
Pros: Programmers get much quicker feedback - easier to debug
Cons: Slower as same section of code may be run multiple times
Programmer needs to distribute source
Customer needs to install the interpreter
Pros and cons of a compiler
Pros: Once compiled once, does not need to be compiled again
Customer does not need to buy a compiler
Programmer does not need to distribute their source.
Cons: Debugging code is slower
Object code only runs on processor type it was initially compiled for
Define Assembler
Program that takes computer instructions and converts them to a pattern of bits that the computer processor can use to perform basic operations. Used by assembly language
Interpreter vs Compiler
Interpreter
Advantage: Can start code straight away
Only needs to translate the line being run
Disadvantage: Needs to interpret every time code is ran
Needs original code and interpreter software every time
Compilers
Advantage: Creates an object code file that can be run without original code and interpreter software.
Object code runs quicker than interpreting
Hides original code
Disadvantage: Needs setup time to complete compilation
Define bytecode
Instruction set (for programming) that is executed on a computer with a virtual machine
Example: Some programming languages do not fully translate to machine code and rather to bytecode. When run the code is typically interpreted. This is a compromise between compilation and interpretation
Pros and cons of bytecode
Pros: Easy to interpret
Independent so it portable
Some protection from viruses as ran on virtual machine.
Cons: Uses more instructions so is slower than higher level languages
Define Opcode and Operand
Opcode: short abbreviations for what an instruction does using mnemonics
Operand: “data” or “inputs” instruction uses, like parameters
Name and define the 2 Addressing modes
Addressing modes: Tells instruction how or where to get any data
Immediate: data is hardcoded into the instruction
Direct: value refers to the address in the main memory where data is to be collected from
Example: Using #5 to get exact value to of 5 while direct would have 5 which refers to the memory address 5