Sec 4. Chap 22 : Programming language translators. Flashcards
Assembler.
Translated assembly language into machine code.
Assembly has a one to one relation with machine code. despite being partially in mnemonic form.
Compiler.
Translate source code from a high-level programming language to a lower level language to create an executable program.
Compilers scan through the source code several times, each time performing checks and building up a table of knowledge needed to produce an accurately reflective machine code object code.
Different processors have different architectures, and therefor each need a specific compiler. Compilers are not platform independent.
Once an object code is compiled it does not need to be be compiled again - saves time and protects source code.
Interpreter.
Interpreters translate code through a series of subroutines to carry out each high level instruction.
Interpreters view each line of the source line-by-line, and calls each specific subroutine to execute that line - an intermediate representation - which is then immediately executed.
Interpreters check language syntax - but not programme logic, so errors can come up later during the programme.
Interpreters do not produce an executable machine code, therefor is always indeed of an interpreter to run the code. This does not protect the source code from plagiarism.
Byte code.
Combines both compiling and interrupting. Usages intermediate representation which combines both.
Bytecode program may be executed by parsing and directly executing the instructions, one at a time.
Byte code can be run in a virtual machine through interpreting line-by-line the code, but also compiled to that specific cpu.
Byte code interpreters takes byte code and converts in into machine code for that particular processor.
Byte code can also be run on virtual machine (its own interpreter), as opposed to the actual pc - protects against harmful software.
Advantages of compilers over interpreters.
Compilers.
Object code only needs to be compiled once / and executes faster. Source code can not be stolen.
Advantages of interpreters over compilers.
Interpreters.
Useful for developers who do not need a lengthy compile time every time the programme is run. Also an easier process to debug because it always crashes where the code is faulty.