Compilation, Interpretation & Subroutines Flashcards
(76 cards)
What are high-level programming languages?
Languages like Java, C/C++, C#, Fortran, Cobol, and Pascal that are easier for humans to use.
What is low-level programming?
Programming with machine code (opcodes), which is hard for humans to read and write.
What is assembly code?
A human-readable form of low-level code that uses mnemonics instead of binary opcodes.
Why must high-level code be converted to machine code?
Because computers can only execute machine code.
What tool translates assembly code into machine code?
An assembler.
What is the role of a linker?
It combines different assembled parts into a complete program.
What does a loader do?
It loads the machine code into memory at a specified location.
What are the two ways to run a high-level program?
By compiling it into machine code or by interpreting it with an interpreter.
What happens when a program is compiled?
It is translated into native machine language and then run directly on the target machine.
Which approach is generally more efficient: compiling or interpreting?
Compiling is usually more efficient (e.g., C/C++ is faster than Python/JavaScript).
What does a compiler do?
It converts source code into object code that performs the same tasks as the original program.
What is a key feature of object code produced by a compiler?
It is usually relocatable, meaning it can be linked and loaded into memory later.
What are the advantages of compilation?
Compilation is done once per program, and the compiler can optimise the code for fast execution by exploiting hardware features.
What are the disadvantages of compilation?
It is harder than interpreting and the resulting program is hardware-dependent.
Where does the compiler run in relation to the target code platform?
The compiler runs on the same platform X as the target code.
What is cross-compilation?
Cross-compilation is when the compiler runs on platform
X, but the target code runs on a different platform Y.
What is an interpreter?
A program that directly reads and follows the source code, performing actions as it goes.
What is an example of the interpretation principle in real life?
Humans following step-by-step instructions or a CPU interpreting machine code.
What are advantages of using an interpreter?
It supports interactive debugging, testing, modifying variables, and invoking procedures from the command line.
What is a major disadvantage of interpretation?
Execution is slower compared to compiled programs.
What does interpretation involve?
Running high-level code directly by an interpreter.
What is the idea behind combining compilation and interpretation?
Compile high-level code into an intermediate language that can be efficiently interpreted.