Programming language translators
Assembler Responsible for converting Low Level Language into machine code Assembly code is equivalent to one machine code instruction Each machine code instruction is dependant on its hardware, so each processor will have a completely different instruction set and a different assembly code. An assembler translates the assembly code into machine code (0s and 1s) The input into the assembler is called the source code and the output is called the object code (machine code).
Compiler Responsible for converting High Level Language (e.g. visual basic python) into machine code. When the source code is entered, the whole program is converted into object code, (this can be quite slow to complete). Different hardware platforms require different compilers. The object code can then be saved on the specific platform and then be run whenever needed without the presence of the compiler
interpreter Responsible for converting High Level Language (e.g. visual basic python) into machine code. An interpreter looks at each line of the source program and analyses it. If it contains no syntax errors, it translators it into machine code and runs it. The translator will scan the whole program checking for certain types of errors before it executes any of it.
Translator A translator converts a high level language such as C++ into machine code that the computer understands. The final file created is often called an 'object file' as it is a chunk of machine code - not necessarily complete in itself.
bytecode Many languages are not only complied or interpreted, but have a in between. Python and Java use intermediate representations which combines compiling and interpreting – the resulting bytecode is then executed by a bytecode interpreter The bytecode may be compiled once (Java) or each time there is a change in source code before executing (python) An advantage is that you can achieve platform independence Any java program has a java Virtual machine(JVM) – a price of software which inherent differences between different computer architecture and OS The JVM can convert the bytecode into machine code for the specific computer.
Compilers vs Interpreters Object code can be saved in disk and run whenever without being recompiled (unless there is an error) Executes faster than interpreted code Object code produced can be distributed/executed without the compiler Object code more secure as cannot be read without ‘reverse engineering’ Appropriate for programs that are going to be run frequently/regularly with the occasional change Platform independence – source code can be run on any machine which has the appropriate interpreter available It is useful for program development – no need for lengthy recompilation each time an error is found. A disadvantage is the program may run slower then a compiled program as each statement has to be translated to machine code each time it is encountered.