Advanced Programming [AP-20]

Code 301AA - 9 Credits


Andrea Corradini <>

Laura Bussi <>
Virtual classroom Advanced Programming Team
Timetable Wednesday 14:15-16:00
Thursday 14:15-16:00
Friday 14:15-16:00
Office hours Click here
Alternatively, to fix a date send an email to <>

Page permanently under construction...

Course description



The final grade is based on the evaluation of the programming assignments that will be proposed along the course, and on a final oral exam. The programming assignments have to be submitted at the very latest ten working days before the oral exam. During the oral exam the lecturer may ask questions about any topic presented during the course as detailed in the Syllabus of the course.

Structure of the Oral Exam

The Oral Exam consists of three parts:
  1. In the first part of the exam (~15 minutes) the student is invited to present one of the topics of the Syllabus, agreed upon with the lecturer. The presentation has to be oral, without the support of slides. Typically, a topic is identified by a number (from 1 to 9) and possibly by one or more letters (eg. 2.b [The JVM Instruction Set], or 8 [An overview of the Rust programming language]). Introductory topics (like 3.a, 5.a, 9.b) will not be accepted.
    In the email proposing the dates for the oral exam (see below) the student has to propose at least two topics among those listed in the syllabus, in decreasing order of preference. The lecturer will make the best effort to assign the preferred topic, unless too many students have chosen the same one.
  2. The second part of the oral exam is dedicated to a discussion about the progamming assignments.
  3. In the third part the lecturer can ask questions about any topic listed in the syllabus.

Exam dates

Students can take the oral exam during the exam sessions, fixing a date with the lecturer. Each student should first register for one of the dates published on the portal, which is only possible after filling the evaluation questionnaire. Next the student should send an email to the lecturer with subject "[AP-20] Oral Exam", proposing some dates for the oral exam (not earlier than five days after the date of the email) and proposing the topics for the first part of the oral exam, as explained above.

Scheduled Oral Exams

The oral exams are public, and take place online in the following Google Meet channel: The student can choose the language (either English or Italian).

Here are dates and locations of the next oral exams. Warning: changes are possible with short notice.

Past exams:

Programming assignments

  1. First programming assignment
  2. Second programming assignment


In order to take full advantage of the course and of being able to pass the final exam in a reasonable time, students are required to have an undergraduate level knowledge of at least one object-oriented programming language (like Java, C++, C# or others) and of at least one functional programming language (like Haskell, OCaml, Scheme or others). Students having a weak background on such topics are strongly encouraged to review by themselves the core notions of Object-Oriented and Functional Programming at the beginning of the course, possibly exploiting the following online material:

For Object-Oriented programming:

For Functional Programming:

Course Schedule

Sep. 16, 2020
Presentation of the course Slides: AP-2020-01.pdf
AP-2020-02.pdf, till page 12
The video of the lesson is accessible on Microsoft Team. If you cannot access it, ask the lecturer.
Sep. 17, 2020
Presentation of the course
Syntax, Semantics and Pragmatics
Programming languages and Abstract Machines (tbc)
Slides: AP-2020-02.pdf, all
AP-2020-03.pdf till page 9.
Sep. 18, 2020
Programming languages and Abstract Machines
Compilation and interpretation schemes
Slides: AP-2020-03.pdf all, Suggested readings: Chapter 1 of Programming Languages: Principles and Paradigms by Maurizio Gabbrielli and Simone Martini
Sep. 23, 2020
Runtime System
The Java Virtual Machine, Runtime Data Areas, Multithreading, ...
Slides: AP-2020-04.pdf, till slide 21. Suggested readings: Chapter 7: Run-time Enviroments Section 7.1, 7.2 and 7.4.1-2 of "The Dragon Book"
Sep. 24, 2020
The Java Virtual Machine: Dynamic Linking, Linking and Loading, Verification,...
Slides: AP-2020-04.pdf, till slide 44. Suggested readings:
JVM Internals, by James D. Bloom
Chapters 1 and 2 of The Java Virtual Machine Specification, Java SE 15 Edition
Reference documentation: The Java Language Specification, Java SE 15 Edition

For the next lesson, please be sure to have installed:
Please check that the downloaded software works correctly on you computer.
Sep. 25, 2020
The JVM: verification, initialition and finalization.
The JVM Instruction Set, start.
Slides: AP-2020-04.pdf, all.
AP-2020-05.pdf, till slide 22.
Suggested readings:
Finalization of Class Instances, Section 12.6 of The Java Language Specification, Java SE 15 Edition
Sep. 30, 2020
The JVM Instruction Set, end.
Slides: AP-2020-05.pdf, all. Suggested readings: Section 2.11 and Chapter 3 of The Java Virtual Machine Specification, Java SE 15 Edition
Java Code To Byte Code - Part One, by James D. Bloom,

Proposed Exercises: Inspecting the JVM

Instructions: exercises_1.html
You can upload you solutions in the folder with you name, accessible under the tab Files of the General channel of Teams (folders are in folder Solutions-01)
Oct. 1, 2020
Exercises: Inspecting the JVM
Instructions: exercises_1.html
Oct. 2, 2020
Software Components: an introduction Slides: AP-2020-06.pdf Suggested readings:
Chapter 1 and Chapter 4 of [COMP], Component Software: Beyond Object-Oriented Programming. C. Szyperski, D. Gruntz, S. Murer, Addison-Wesley, 2002.
Oct. 7, 2020
Software Components: the Sun approach, JavaBeans Slides:
AP-2020-07.pdf, till slide 23.
Suggested activity:
Practice with Netbeans and with the use/development of Java Beans reading the Oracle JavaBeans Tutorial
Suggested readings:
Oct. 8, 2020
Java Beans and Reflection in programming languages Slides: AP-2020-07.pdf, all
AP-2020-08.pdf, till slide 11.
Suggested activity and readings: see above.
Oct. 9, 2020
Reflection in Java
Annotations in Java (start)
AP-2020-08.pdf, till slide 44.
Suggested readings:
The Java Tutorial on Reflection API, excluding Arrays and Enumerated Types.
The Java Tutorial on Annotations.
Proposed exercises: exercises_2.html
Exercises: Java Beans, Reflection and Annotations
Instructions: exercises_2.html
You are invited to upload your solutions on the Team of the course, in the folder with your name under Solutions-02
Oct. 14, 2020
Annotations in Java (end)
Software Components: the Microsoft way (start)
Slides: AP-2020-08.pdf, all.
AP-2020-09.pdf, till slide 24.
Suggested readings:
The Java Tutorial on Annotations.
Chapter 15 of [COMP], sections 15.1, 15.11, 15.12.
Oct. 15, 2020

The .NET Framework
Slides: AP-2020-09.pdf, till slide 55. Suggested readings:
Chapter 15 of [COMP], sections 15.1, 15.11, 15.12.
Oct. 16, 2020
Delegates in C#, Frameworks and Inversion of Control Slides: AP-2020-09.pdf, all.
AP-2020-10.pdf, till slide 18.
Suggested readings:
Oct. 21, 2020
Inversion of Control and Dependency Injection in Software Frameworks Slides: AP-2020-10.pdf, all
Suggested readings:
Oct. 22, 2020
.NET Core and Microsoft Strategies Invited lesson by Prof. Antonio Cisternino Video
Oct. 23, 2020
On Designing Software Frameworks Slides: AP-2020-11.pdf, all
Suggested readings:
Oct. 28, 2020
  • A classification
  • Overloading & Coercion
  • Inclusion polymorphism & Overriding
  • Explicit parametric polymorphism: Templates in C++.
AP-2020-13.pdf, till page 12.

Compiler Explorer:
(a site for exploring compiled code)

Suggested readings:
Oct. 29, 2020
Universal Parametric Polymorphism:
C++ Templates and Java Generics
  • C++ templates
  • Java Generics
  • Bounded type parameters
  • Generics and inheritance: invariance, covariance and contravariance
Slides: AP-2020-13.pdf (C++ templates) all
AP-2020-14.pdf (Java Generics), till page 15.

Compiler Explorer:
(a site for exploring compiled code)
Some C++ code: listings.cpp

Suggested readings:
Oct. 30, 2020
  • Java Generics
  • The Standard Template Library for C++
Slides: AP-2020-14.pdf (Java Generics), till page 15.
An overview of the STL.
Suggested readings:
Nov. 4, 2020
Introduction to Functional Programming
  • Historical origins
  • Main concepts
  • Language families: LISP, ML, Haskell
  • Core concepts on Haskell, lazy evaluation
Slides: AP-2020-16.pdf, till page 19. Suggested readings:
Students are invited to install the Glasgow Haskell Compiler and Interpreter (GHCI) downloadable from
Nov. 5, 2020
  • Core concepts on Haskell, lazy evaluation
  • The lambda-calculus: syntax and beta-reduction
  • Church Booleans, Pairs and Numerals, Arithmetics
  • Fixpoint operator and recursion
AP-2020-16.pdf, all.
AP-2020-17.pdf, till page 13.
Suggested readings:
Nov. 6, 2020
More on lambda-calculus and on Haskell
  • Evaluation orders
  • Call by need in Haskell
  • List comprehension
  • Algebraic Data Types
  • Higher-order functions and combinators
Slides: AP-2020-17.pdf, all
AP-2020-18.pdf, till page 16
Suggested readings:
Nov. 11, 2020
Exercises on Functional Programming in Haskell.

We will try to have some interactions with you exploting please create a personal account there.

Proposed exercises: exercises_3.html

You are invited to upload the solutions to the exercises you managed to solve on Teams, in the folder with your name in Solutions-03.

If you are new to functional programming, or if you want to refresh the essence of it, I strongly recommend reading the blog Mary Rose Cook, A practical introduction to functional programming, if you did not yet.

Students are invited to install the Glasgow Haskell Compiler and Interpreter (GHCI) downloadable from
An excellent tutorial on Haskell:

Nov. 12, 2020
Type classes in Haskell Slides:
Suggested readings:
Nov. 13, 2020
Constructor Classes and Monads in Haskell
Slides: AP-2020-20.pdf, till page 33. Suggested readings:
Nov. 18, 2020
Presentation of programming assigments on JavaBeans and Reflection in Java. First programming assignment [Suggested deadline: December 20, 2020]

Nov. 18, 2020
The IO Monad in Haskell
Lambda expressions in Java 8
Slides: AP-2020-20.pdf, all
AP-2020-21.pdf, till page 6.
Suggested readings:
Nov. 19, 2020
Lambda expressions in Java 8
The Stream API in Java 8
Slides: AP-2020-21.pdf, all
AP-2020-22.pdf till slide 10.
Suggested readings:
Nov. 20, 2020
The Stream API in Java 8
Exercises: Implementing Haskell constructor classes with C++ templates (Laura Bussi)
Slides: AP-2020-22.pdf all. Suggested readings:
Nov. 25, 2020
The RUST programming language Slides: AP-2020-23.pdf, till page 33 Suggested readings:
Nov. 26, 2020
Other aspects of RUST
Scripting Languages
Slides: AP-2020-23.pdf
Suggested readings:
Nov. 27, 2020
  • Exercises on the Stream API and on partial functions in Java 8.
  • Optional exercise on C++ Templates
Java Stream API: exercises_4.html
Auxiliary file: people.csv
C++ Templates: EsSemiringTemplates.html
Suggested readings:
Use of Optional in Java,
Dec. 2, 2020
Introduction to Python
  • Basic and Sequence Datatypes
  • Dictionaries
  • Control Structures
Slides: AP-2020-25-Python.pdf, till page 62. Suggested readings:
Dec. 3, 2020
More about Python
  • List Comprehension
  • Function definition
  • Positional and keyword arguments
  • Functions as objects
  • Higher-order functions
  • Combinators vs. list comprehension
  • Decorators
  • Namespaces and Scopes
Slides: AP-2020-25-Python.pdf, all. AP-2020-26-Python-OOP.pdf, till page 27. Suggested readings:
Dec. 4, 2020
  • Object Oriented Programming in Python (cont′d)
  • Inheritance
  • Iterators and generators
  • Garbage collection in CPython
  • The Global Interpreter Lock
  • Miscellaneous criticisms to Python
  • Browsing the Python documentation
  • Builtin functions
  • Python Standard Library
  • Examples of scripts in Python
AP-2020-26-Python-OOP.pdf, all. AP-2020-27-GIL-etAl.pdf, till page 7.
Dec. 9, 2020
Exercises on Python
Instructions: exercises_5.html
Auxiliary files: anagram.txt, people.csv

Dec. 16, 2020
Second programming assignment [Suggested deadline: January 8, 2021]