PLP: Lecture 1
Administrivia
1 major project. 7 parts.
- Scanner
- Parser
- Abstract Syntax Tree
- Type Checking
- Code Generation 1
- Code Generation 2
- Fix errors and submit
Will generate java byte code. Grading will be done on junit tests.
Notes
Reading: Scott, CH 1
What makes languages successfull?
- Expressive power
- Most programming languages are Turing complete! What does this mean? We’ll find out next semester in Formal Languages :)
- Ease of implementation and availability
- Ease of use for novice
- Standardization
- Excellent Compilers
- Fortran has a good compiler which has kept it alive. At some point, look this up?
- Economics, patronage, and inertia
Declarative and Imperative Languages
Imperative: Like Java, C++, etc. Have a notion of variables whose values you update.
Declarative: Functional, logic, query languages.
Compilation
In a nutshell- a compiler translates a source program to an equivalent program in a target language. Output is called object code when written to a file in a form understood by the OS.
Preprocessors remove comments and expand macros, and may delete code to allow for conditional compilation.
Linkers are for linking to external libraries.
Interpreters
Essentially implement a virtual machine. Fetches, analyzes, and executes source code (more or less) one instruction at a time.
Can be combined with compilation.
Example: Java
Early implementations compiled Java source with javac to create byte code. This was interpreted by the JVM. The JVM simulated a stack oriented machine. Has exceptions, threads, and other fancy features.
Currently, java source code is compiled via javac to byte code. This gets interpreted or gets compiled again by a “just in time” (JIT) compiler, which generates machine code.