Lectures

This page gives highlights of past lectures and provides lecture notes, reading assignments, and exercises.

Chapters, sections and exercises in readings are from the main textbook, unless specified otherwise.

Readings on F# link directly to online resources, such as examples or the Wikibook on F# Programming.


Dates Topics Exercises
Aug 23
Aug 25

Course introduction and administration. Overview of course topics. Programming language paradigms. Brief history of programming languages. Compilation vs. intepretation. Issues and factors in programming language design.

Readings:

 
Aug 30

An introduction to F#. Basic types and operators. Basic expressions and type checking. Variable binding. Variable scope ands scoping rules. Function definitions. Tuple types.

Readings:

 
Sep 1

More on F#. Pattern matching. Patterns in let expressions and in function definitions. The match construct. Meaning and common uses. Scoping of pattern variables in match.

Readings:

 
Sep 6

Algebraic datatypes (ADT), or discriminated unions, in F#. Basic uses. Pattern matching with ADTs. Functions accessing and manipulating ADTs. Using ADTs to encode arithmetic expressions. Simple evaluators of arithmetic expressions.

Readings:

 
Sep 8

Parametric types in F#. Motivation and uses. Parametric algebraic datatypes. F# Lists. Basic features and examples. Using pattern matching and recursion to implement functions over lists.

Readings:

 
Sep 13

No class

 
Sep 15

Implementing finite sets in F# using lists. Extending the basic expression language with variables and with let binders. Free and bound variables, variable scope. Evaluating expressions with let binders. Examples.

Readings:

  • Lecture code 5
  • Sect. 2.1-2.3 of Sestoft

All ex. in code 5  
Sep 20
Sep 22

Compiling expressions with variable names to expressions with variable indices. Stack machines for expression evaluation, with variables and without. Compiling expressions to stack machine code. Running stack machine code. Implementing an abstract machine in Java. Examples.

Readings:

  • Lecture code 6
  • Chap. 2 of Sestoft

All ex. in code 6  
Sep 27

Formal languages. Regular expressions. Languages generated by regular expressions. Finite Automata. Finite automata as recognizers of regular languages.

Readings:
Lecture notes by Wayne Goddard on

  1. Finite Automata
  2. Regular Expressions
Recommended readings:
Lecture notes by Wayne Goddard on

Practice problems in today's readings  
Sep 29

Non-deterministic finite-state automata (NFAs). Definition and examples. Relationships between NFAs, deterministic automata and regular expressions. Context-free grammars and languages. Definition and examples.

Readings:
Lecture notes by Wayne Goddard on

  1. Nondeterministic Finite Automata
  2. Context-Free Grammars
Practice problems in today's readings  
Oct 4

Midterm I  

 
Oct 6

More on context-free grammars and languages. Systematically generating CFG's from regular expressions. Derivations and derivation trees. Ambiguous grammars. Examples and exercises. Pushdown automata. Recognizing context-free languages with pushdown automata. Examples.

Readings:
Lecture notes on

  1. Context-Free Grammars (by Wayne Goddard)
  2. Derivation Trees (by Wayne Goddard)
Recommended readings:
Lecture notes on

Practice problems in today's readings  
Oct 11

More on derivations and derivation trees. From concrete to abstract syntax. Lexers, parsers and generators. Specifying lexers and parsers in F# with fslex and fsyacc. A concrete syntax and a lexer and parser for a simple language of expressions.
Discussion of Midterm I solutions and grades.

Readings:

  1. Sect. 3.1-3.6 of Sestoft
  2. Expr code (see README files in zip archive)
  3. Midterm sample solutions (Note @149 on Piazza)
Recommended readings:
Lecture notes on
  • Sect. 3.8 of Sestoft

 
Oct 13

More on automatically generated parsers. Example of pushdown automaton parser generated by fsyacc.
Micro-ML, a simple language of recursive functions: concrete and abstract syntax. Closures. Lexer and parser specification.

Readings:

  1. Sect. 4.1-4.4 of Sestoft

 
Oct 18
Oct 20

Examples of micro-ML programs. Interpreting micro-ML. Specifying interpreters formally with evaluation rules. Implementation of specification in F#, via eval function. Static and dynamic scope. Adding type-checking to micro-ML. Formal type-checking rules. Implementation of type checker. Static vs. dynamic typing.

Readings:

  1. Sect. 4.1-4.10 of Sestoft
  2. Fun code (see README files in zip archive)
  3. TypeFun code
Recommended readings:

 
Oct 25

Higher-order functions in F#. Currying and partial evaluation. Higher-order combinators. Examples.

Readings:

  1. Sect. 5.1-5.5 of Sestoft
  2. Functions as First-Class Values
  3. Lecture code 7

 
Oct 27

Extending micro-ML to higher-order functions. Comparison between interpreters for first-order and higher-order micro-ML. Examples of higher-order programming in Micro-ML

Records in F#. Mutable and immutable fields. Mutable variables.

Readings:

  1. Sect. 5.1-5.5 of Sestoft
  2. HighFun code (see README files in zip archive)
  3. Lecture code 8
Recommended readings:

 
Nov 1
Nov 3

Imperative programming. Main concepts. Programs as state transformers. A naive imperative language. Environment and Store. The C programming language. Integers, pointers and arrays in C. Type declarations in C. The micro-C language.

Readings:

  1. Sect. 7.1-7.5 of Sestoft
  2. Lecture notes on micro-C
Recommended readings:

 
Nov 8

Additional F# features. Alternative syntax for parametric types. Immutable maps. Option types and their uses. Sequencing of expressions with the ; operator.
Discussion of Hw4.

Readings:

  1. Lecture code 9
  2. F# : Option Types
Recommended readings:

 
Nov 10

Parameter passing mechanisms in various programming languages.
Interpreting micro-C programs. Local and global environments. Memory model. Store and activation records. Interpreting statements, declarations, expressions, and variable access in the presence of side effects. Relationship between & (address) and * (pointer dereferencing) operators.

Readings:

  1. Sect. 7.1-7.7 of Sestoft
  2. Lecture notes on micro-C (revised)
Recommended readings:

 
Nov 15

Midterm II

   
Nov 17

An virtual stack machine for micro-C. Instruction set, concrete and symbolic. Virtual machine as implemented in Java. The structure of the runtime stack. Compiling micro-C to machine code: overview of main approach.

Readings:

  1. Sect. 8.1-8.8 of Sestoft
  2. Lecture notes on micro-C compilation
  3. MicroC code (see README files in zip archive)
Recommended readings:

Exercises in lecture notes
Nov 22 Nov 24

Thanksgiving break

 
Nov 29
Dec 1

More on micro-C compilation. Examples of compilation. Compilation to real machine code.
An overview of basic concepts in object-oriented languages. Memory model for object oriented languages. Stack and heap allocation.

Readings:

  1. Chap 8 of Sestoft

 
Dec 6

Real-world virtual machines. An overview of the Java virtual machine. Main differences with CLI (.NET) virtual machine. Byte code verification. Just-in-time compilation.

Readings:

  1. Chap 9 of Sestoft

 
Dec 8

Discussion of course project.
Garbage collection. Review of stack and heap allocation. The free list. Garbage collection techniques. Reference counting. Mark-sweep collection. Two-space stop-and-copy collection. Generational GC. Conservative GC. Garbage collectors in various languages.

Readings:

  1. Chap 10 of Sestoft