














































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!















































Lecture 2: Compilation and Interpretation
COMP 514 Programming Language Concepts
Aaron Block
January 16, 2007
Based on notes by N. Fisher, F. Hernandez-Campos, and D. Stotts
Goals
code into machine executable code.
Compilation
Source Program
Compiler
Target Program Input
Output
Compilation
Source Program
Compiler
Target Program Input
Output
The “ target program ” is called the object
code.
Interpretation
Interpreter
Source Program Input
Output
Interpretation
Interpreter
Source Program Input
Output
You translate for each run.
Comparison
Source
Compiler
Target
In
Out
Source
In
Out
Compilers are usually faster than
interpreters.
Interpreter
Comparison
Source
Compiler
Target
In
Out
Interpreter
Source
In
Out
Interpreters are usually more flexible and
easier to debug than compilers.
Compilation and Interpretation
Source Program
Translator
Intermediate
Program
Input
Output
Virtual
Machine
The Virtual Machine acts as an
interpreter.
Compilation and Interpretation
Source Program
Translator
Intermediate
Program
Input
Output
Virtual
Machine
The translator can be a compiler or an
interpreter. It is considered to be a compiler if:
1. There is a thorough analysis of the program 2. The transformation is non-trivial.
Linking
Source Program
Compiler
Library
Routines
Incomplete machine language
Linker
Machine
language
program
Linking
Source Program
Compiler
Library
Routines
Incomplete machine language
Linker
Machine
language
program
The Linker is used to connect subroutines that
are not contained in the original code.
Preprocessing
Source Program
Preprocessor
Modified source program
Preprocessing
Source Program
Preprocessor
Modified source program
For example, this may be used to remove
comments or use replacement macros.