SLR 15 - programming languages and translators Flashcards
What is the difference between how programs that have been compiled and programs that have been interpreted can run?
Compiled programs can be run without requirement for any other software to be present. This is not the case with interpreters
How do interpreters work?
- They have procedures that can be used to translate each kind of program instruction
- They check for errors as they translate rather than before
- A program with errors with be partially translated until the error is reached
How is bytecode executed?
- With a virtual machine which can execute bytecode of different processors
- Each different processor instruction set will have its own virtual machine
Why do we need translators?
A program needs to be in machine code to be executed, so translators are needed to convert HLL and Assembly language into machine code (binary)
What are the 3 types of translator?
- assembler
- interpreter
- compiler
What does an assembler do?
It converts assembly language into machine code
Why is assembly language translation quick and easy?
- an assembly language instruction has a one to one relationship with machine code
- this means translation is quick
Why do different assembler need to exist for each different type of processor instruction set?
They are platform specific
What do compilers do?
They translate programs written in high-level languages into machine code
How do compilers work?
- They take the HLL as their source code
- They check it for any errors
- Then translate the whole program at once
- If there is an error the source code then it will not be translated
Why are compilers deemed platform specific?
They produce machine code
What do interpreters do?
- they translate HLL into machine code LINE BY LINE
Why do interpreters offer poor protection for their source code?
- during translation, the program source code and the interpreter must be present
- it makes the original code difficult to extract
Advantages of interpreters?
- useful when writing programs
- no need for lengthy, time consuming recompilation every time an error is found
- makes it much easier to partially test and debug programs
Advantages of compilers?
- Generated object code is kept on a disk, it can be run when needed without needing to recompile it
- once created, object code executes much faster then interpreted code
- the object code is relatively secure, it is hard to read it and work out what the source code would have been (protected from extraction)