Advanced Programming [AP-23]

Code 301AA - 9 Credits


LECTURER

Tutor
Andrea Corradini <andrea.corradini@unipi.it>

Laura Bussi <laurabussi@live.it>
Virtual classroom To be used only in case of sanitary emergence. Advanced Programming Microsoft Team
Timetable Monday 11:00 - 13:00, Room M1
Tuesday 11:00 - 13:00, Room C1
Wednesday 9:00 - 11:00, Room C
Office hours By appointment sending an email to <andrea@di.unipi.it>.
Recordings of lessons of AY 2021/22 The recordings are accessible here. The topics of each lesson can be found in page AP-21

Page permanently under construction...

Course description

See: https://esami.unipi.it/programma.php?c=60309&aa=2023&docente=CORRADINI&insegnamento=&sd=0

Evaluation

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 6.c-d [Type classes and Monads in Haskell]). Introductory topics (like 3.a, 5.a, 9.a) will not be accepted alone.
    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 https://esami.unipi.it/esami2/, which is only possible after filling the evaluation questionnaire. Next the student should send an email to the lecturer with subject "[AP-23] Oral Exam", proposing some dates for the oral exam (not earlier than ten days after the date of the email) and proposing the topics for the first part of the oral exam, as explained above.
Note: The date of the oral exam can be fixed independently of the date published in the portal, also before that date. In particular, upon request, in January 2024 an oral exam can take place also before 17-01-2024,

Scheduled Oral Exams

The oral exams are public, and take place in presence. The student can choose the language (either English or Italian). Here are the dates of the next oral exams. "Sala Seminari Ovest", "Sala Seminari Est" and "Sala Riunioni Est" are in the Dipartimento di Informatica.
Warning: changes are possible with short notice. Past exams:

Programming assignments

  1. First programming assignment
  2. Second programming assignment

Prerequisites

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 should inform the lecturer at the beginning of the course, and 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:

Videos of the lessons of Advanced Programming 2021/22

The present course will be held in presence. The lectures held in the AY 2021/22 were recorded due to the pandemic. The recordings are accessible here. The topics of each lesson can be found in the page of Advanced Programming, AY 2021/22

Course Schedule

N.
DATE
TOPIC
SLIDES
NOTES
1
Sep. 19, 2023, 11:00-13:00
Presentation of the course Slides: AP-2023-01-CourseOverview.pdf
AP-2023-02-MotivationsIntro.pdf
Students attending the course are asked to fill in this FORM, thanks!
2
Sep. 20, 2023
Syntax, Semantics and Pragmatics
Programming languages and Abstract Machines
Compilation and interpretation schemes
Slides: AP-2023-03-Compilation-Interpretation.pdf Suggested readings: Chapter 1 of Programming Languages: Principles and Paradigms by Maurizio Gabbrielli and Simone Martini

Compiler explorer: http://www.godbolt.org
3
Sep. 25, 2023
The Java Virtual Machine: architecture and runtime data areas. Slides: AP-2023-04-Intro2JVM.pdf,till page 29. Suggested readings: Chapter 7: Run-time Enviroments Section 7.1, 7.2 and 7.4.1-2 of "The Dragon Book"
JVM Internals, by James D. Bloom http://blog.jamesdbloom.com/JVMInternals.html
4
Sep. 26, 2023
Disassembling class files
The Java Virtual Machine: Initialization and Verification.
The JVM Instruction Set: properties, format and addressing modes.
Slides: AP-2023-04-Intro2JVM.pdf, all.
AP-2023-05-JVM-InstructionSet.pdf, till page 19.
Suggested readings:
JVM Internals, by James D. Bloom http://blog.jamesdbloom.com/JVMInternals.html
Chapters 1 and 2 of The Java Virtual Machine Specification, Java SE 17 Edition
Reference documentation: The Java Language Specification, Java SE 17 Edition
5
Sep. 27, 2023
The JVM Instruction Set, end.
Just In Time compilation in the HotSpot JVM
Slides: AP-2023-05-JVM-InstructionSet.pdf, all. Suggested readings: Section 2.11 and Chapter 3 of The Java Virtual Machine Specification, Java SE 17 Edition
Java Code To Byte Code - Part One, by James D. Bloom, http://blog.jamesdbloom.com/JavaCodeToByteCode_PartOne.html
How the JIT compiler boosts Java performance in OpenJDK, by Roland Westrelin, https://developers.redhat.com/articles/2021/06/23/how-jit-compiler-boosts-java-performance-openjdk
6
Oct. 2, 2023
Software Components: an introduction Slides: AP-2023-06-SoftwareComponentsIntro.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.

For the lesson of Wed. 4/10, please be sure to have installed:
Please check that the downloaded software works correctly on your computer.
7
Oct. 3, 2023
Software Components: the Sun approach, JavaBeans
Slides: AP-2023-07.JavaBeans.pdf
Suggested readings:
8
Oct. 4, 2023
Exercises: Inspecting Java bytecode and the JVM

You can send your solutions to the lecturer with an email with subject "[AP-23] Solutions to EX 1". Do not send JAR files.

Proposed Exercises: Inspecting the JVM

Instructions: exercises-1-2023.pdf
Other files: WrongQueue.java
For this lesson please be sure to have installed:
Please check that the downloaded software works correctly on your computer.
9
Oct. 9, 2023
Reflection in Java
Annotations in Java
Slides:
AP-2023-08-Reflection.pdf.
Suggested readings:
The Java Tutorial on Reflection API, excluding Arrays and Enumerated Types.
The Java Tutorial on Annotations.
10
Oct. 10, 2023
Polymorphism:
  • A classification
  • Overloading & Coercion
  • Inclusion polymorphism & Overriding
  • Explicit parametric polymorphism: Templates in C++.
Slides:
AP-2023-09-Polymorphism.pdf
AP-2023-10-Templates.pdf (up to page 10)

Compiler Explorer: https://godbolt.org/
(a site for exploring compiled code)

Suggested readings:
11
Oct. 11, 2023
Exercises: Java Beans, Reflection and Annotations
Instructions: exercises_2.html
For this lesson we suggest to use Apache NetBeans.
We will start with a quick look at the Oracle JavaBeans Tutorial
12
Oct. 16, 2023
Universal Parametric Polymorphism:
C++ Templates and Java Generics
  • C++ templates
  • Java Generics
  • Bounded type parameters
Slides: AP-2023-10-Templates.pdf (C++ templates) all
AP-2023-11-Generics.pdf (Java Generics) up to page 16.

Compiler Explorer: https://godbolt.org/
(a site for exploring compiled code)

Suggested readings:
Java Generics tutorials:
13
Oct. 17, 2023
Covariance of Arrays in Java
Limitations of Generics.
The Standard Template Library for C++
Slides: AP-2023-11-Generics.pdf (Java Generics), all.
AP-2023-12-STL.pdf (STL) up to page 12.

Suggested readings:
14
Oct. 18, 2023
The Standard Template Library for C++ (cont.)
Introduction to Functional Programming
  • Historical origins
  • Main concepts
  • Language families: LISP, ML, Haskell
Slides: AP-2023-12-STL.pdf (STL), all
AP-2023-13-FP.pdf (Functional Programming), up to page 7.
Suggested readings:
Students are invited to install the Glasgow Haskell Compiler and Interpreter (GHCI) downloadable from https://www.haskell.org/
15
Oct. 23, 2023
Core concepts of Haskell Slides: AP-2023-13-FP.pdf (Functional Programming), all. Suggested readings: see previous lesson
16
Oct. 24, 2023
More on Haskell
  • List comprehension
  • Algebraic Data Types
  • Higher-order functions and combinators
Slides: AP-2023-15-Haskell2.pdf Suggested readings:
17
Oct. 25, 2023
Exercises on fuctional programming with Haskell
Instructions: exercises_3.html

Online documentation of Haskell functions:

Students are invited to install the Glasgow Haskell Compiler and Interpreter (GHCI) downloadable from https://www.haskell.org/downloads/

Students are invited to complete the exercises at home and to send their solutions to the lecturer, as attachments to an email with subject "[AP-23] Exercise 3 - solutions".

18
Oct. 30, 2023
  • Lazy evaluation
  • The lambda-calculus: syntax and beta-reduction
  • Church Booleans, Pairs and Numerals, Arithmetics
  • Fixpoint operator and recursion
  • Evaluation orders in lambda-calculus
  • Call by need in Haskell
  • Other parameter passing mechanisms
Slides: AP-2023-14-Lambda.pdf Suggested readings:
19
Oct. 31, 2023
Type classes in Haskell Slides:
AP-2023-16-TypeClasses_inference.pdf, up to page 33.
Suggested readings:
20
Nov. 6, 2023
Type inference
Constructor Classes and Monads in Haskell
Slides:
AP-2023-16-TypeClasses_inference.pdf, all.
AP-2023-17-Monads.pdf, till page 15.
Suggested readings:
21
Nov. 7, 2023
More on Constructor Classes and Monads in Haskell
Input-Output in Hakell: the IO Monad
Type (un)safety in Haskell: unsafePerformIO
Slides:
AP-2023-17-Monads.pdf, all.
Suggested readings:
22
Nov 8, 2023
Proposed exercises on Type Classes in Haskell Exercises on Type Classes in Haskell: exercises_4.html
Online documentation of Haskell functions:
Students are invited to install the Glasgow Haskell Compiler and Interpreter (GHCI) downloadable from https://www.haskell.org/downloads/

Students are invited to complete the exercises at home and to send their solutions to the lecturer, as attachments to an email with subject "[AP-23] Exercise 4 - solutions".

23
Nov. 13, 2023
Lambda expressions in Java 8 Slides: AP-2023-18-JLambdas.pdf Suggested readings:
24
Nov. 14, 2023
The Stream API in Java 8 Slides: AP-2023-19-JStreams.pdf. Suggested readings:
25
Nov 15, 2023
Proposed exercises on Java Stream API Exercises on Java Stream API: exercises_5.html
Auxiliary file: people.csv
Students are invited to complete the exercises at home and to send their solutions to the lecturer, as attachments to an email with subject "[AP-23] Exercise 5 - solutions".
Nov. 15, 2023
Programming assigments on JavaBeans, Reflection and Annotations in Java, and on Haskell. First programming assignment [Suggested deadline: December 20, 2023, flexible]
26
Nov. 20, 2023
Frameworks and Inversion of Control Slides: AP-2023-20-IOC.pdf Suggested readings:

27
Nov. 21, 2023
On Designing Software Frameworks Slides: AP-2023-21-DesigningFrameworks.pdf Suggested readings:
28
Nov. 22, 2023
The Java Memory Model Slides: AP-2023-22-JavaMemoryModel.pdf. The reading material for the JMM is: [Manson05] Jeremy Manson, William Pugh, and Sarita V. Adve. The Java memory model. In POPL '05: 378-391 [see also here]
Additional material:

29
Nov. 27, 2023
The RUST programming language: An introduction (Part 1) Slides: AP-2023-23-RUST.pdf. Suggested readings from the Rust book:
  • Foreword, Introduction
  • Chapter 1 - Getting Started
  • Chapter 3 - Common Programming Concepts
  • Chapter 4 - Understanding Ownership
30
Nov. 28, 2023
The RUST programming language: An introduction (Part 2) Slides: AP-2023-24-RUST.pdf, till page 22. Suggested readings from the Rust book:
  • Chapter 6 - Enums and Pattern Matching
  • Chapter 10 - Generic Types, Traits and Lifetimes
31
Nov. 29, 2023
The RUST programming language: An introduction (Part 3) Slides: AP-2023-25-RUST.pdf. Suggested readings from the Rust book:
  • Chapter 15 - Smart Pointer
  • Section 19.1 - Unsafe Rust
32
Dec. 4, 2023
An introduction to Python Slides: AP-2023-26-PythonIntro.pdf. Suggested readings:
33
Dec. 5, 2023
Functional programming in Python Slides: AP-2023-27-Python-Functions.pdf. Suggested readings:
34
Dec. 6, 2023
OOP in Python, Multi-threading and the GIL Slides: AP-2023-28-Python-OOP.pdf. Suggested readings:
Dec. 6, 2024
Second programming assignment

Links