Advanced Programming [AP-24]

Code 301AA - 9 Credits


LECTURER Andrea Corradini <andrea.corradini@unipi.it>
Timetable Monday 11:00 - 13:00, Room Fib L1
Tuesday 11:00 - 13:00, Room Fib L1
Wednesday 16:00 - 18:00, Room Fib C
Office hours By appointment sending an email to <andrea.corradini@unipi.it>.
Recordings of lessons of AY 2021/22 The course is held in presence, and lessons are not recorded. The recordings of the AY 2021/22 are accessible from here

Page permanently under construction...

Course description

See: https://unipi.coursecatalogue.cineca.it/insegnamenti/2024/52756_691454_67343/2012/52756/10434?coorte=2024&schemaid=9087

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. Information about the structure of the oral exam will be published towards the end of the course.

Students who cannot attend the course for valid reasons (e.g. visa problems) can ask the lecturer (as soon as possible, not later than the end of the course) to bring the 2021/22 academic year program, for which they can find the recordings of the lessons on page https://pages.di.unipi.it/corradini/Didattica/AP-21/.


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:

Course Schedule

N.
DATE
TOPIC
SLIDES
NOTES
1
Sep. 16, 2024, 11:00-13:00
Presentation of the course Slides: AP-2024-01-CourseOverview.pdf
AP-2024-02-MotivationsIntro.pdf
Students attending the course are asked to fill in this FORM, thanks!
2
Sep. 17, 2024
Syntax, Semantics and Pragmatics
Programming languages and Abstract Machines
Compilation and interpretation schemes
Slides: AP-2024-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. 18, 2024
The Java Virtual Machine: architecture and runtime data areas. Slides: AP-2024-04-Intro2JVM.pdf,till page 32. 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
Chapters 1 and 2 of The Java Virtual Machine Specification, Java SE 17 Edition
4
Sep. 23, 2024
Disassembling class files
The Java Virtual Machine: Initialization and Verification.
The JVM Instruction Set: properties, format and addressing modes.
Slides: AP-2024-04-Intro2JVM.pdf, all.
AP-2024-05-JVM-InstructionSet.pdf, till page 10.
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. 24, 2024
The JVM Instruction Set, end.
Just In Time compilation in the HotSpot JVM
Slides: AP-2024-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
Wednesday Sep. 25, 2024, Room C
Exercises: Inspecting Java bytecode and the JVM

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

Proposed Exercises: Inspecting the JVM

Instructions: exercises-1-2024.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.
6
Sep. 30, 2024
Software Components: an introduction Slides: AP-2024-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.
7
Oct. 1, 2024
Software Components: the Sun approach, JavaBeans
Slides: AP-2024-07.JavaBeans.pdf
Suggested readings:
8
Oct. 2, 2024
Reflection in Java
Annotations in Java
Slides:
AP-2024-08-Reflection.pdf.
Suggested readings:
The Java Tutorial on Reflection API, excluding Arrays and Enumerated Types.
The Java Tutorial on Annotations.
9
Oct. 7, 2024
Frameworks and Inversion of Control Slides: AP-2024-09-IOC.pdf Suggested readings:

10
Oct. 8, 2024
On Designing Software Frameworks Slides: AP-2024-10-DesigningFrameworks.pdf Suggested readings:
11
Oct. 9, 2024
Exercises: Java Beans, Reflection and Annotations
You can send your solutions to the lecturer with an email with subject "[AP-24] Solutions to EX 2". If you want to send a JAR file, change the suffix of the file for example to RAJ, otherwhise GMAIL will block it.
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. 14, 2024
Polymorphism:
  • A classification
  • Overloading & Coercion
  • Inclusion polymorphism & Overriding
  • Explicit parametric polymorphism: Templates in C++.
Slides:
AP-2024-11-Polymorphism.pdf
AP-2024-12-Templates.pdf (up to page 15)

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

Suggested readings:
13
Oct. 15, 2024
Universal Parametric Polymorphism:
C++ Templates and Java Generics
  • C++ templates
  • Java Generics
  • Bounded type parameters
Slides: AP-2024-12-Templates.pdf (C++ templates) all
AP-2024-13-Generics.pdf (Java Generics) up to page 25.

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

Suggested readings:
14
Oct. 16, 2024
Wildcards in Java
Limitations of Generics.
The Standard Template Library for C++
Slides: AP-2024-13-Generics.pdf (Java Generics), all.
AP-2024-14-STL.pdf (STL).

Suggested readings:
15
Oct. 21, 2024
Introduction to Functional Programming
  • Historical origins
  • Main concepts
  • Language families: LISP, ML, Haskell
  • Core concepts on Haskell
Slides: AP-2024-15-FP.pdf (Functional Programming) Suggested readings:
Students are invited to install the Glasgow Haskell Compiler and Interpreter (GHCI) downloadable from https://www.haskell.org/
16
Oct. 22, 2024
More on Haskell...
  • List comprehension
  • Algebraic Data Types
  • Higher-order functions and combinators
  • Tail Recursion Optimization
  • Converting recursion into Tail Recursion
Slides: AP-2024-16-Haskell2.pdf Suggested readings:
17
Oct. 23, 2024
Exercises on functional programming with Haskell
You can send your solutions to the lecturer with an email with subject "[AP-24] Solutions to EX 3".
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/
18
Oct. 28, 2024
  • 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-2024-17-Lambda.pdf Suggested readings:
19
Oct. 29, 2024
Type classes in Haskell
Type inference
Slides:
AP-2024-18-TypeClasses_inference.pdf, up to page 40.
Suggested readings:
20
Oct. 30, 2023
Type inference
Constructor Classes and Monads in Haskell
Slides:
AP-2024-18-TypeClasses_inference.pdf, all.
AP-2024-19-Monads.pdf, till page 17.
Suggested readings:
 
Nov. 4, 2024
The lesson of Monday, November 4 is canceled because of unavailability of the lecturer
21
Nov. 5, 2024
More on Constructor Classes and Monads in Haskell
Input-Output in Hakell: the IO Monad
Type (un)safety in Haskell: unsafePerformIO
Slides:
AP-2024-19-Monads.pdf, all.
Suggested readings:
22
Nov. 6, 2024
Exercises on Type Classes in Haskell
You can send your solutions to the lecturer with an email with subject "[AP-24] Solutions to EX 4".
Instructions: 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/

23
Nov. 11, 2024
Lambda expressions in Java 8 Slides: AP-2024-20-JLambdas.pdf Suggested readings:
24
Nov. 12, 2024
The Stream API in Java 8 Slides: AP-2024-21-JStreams.pdf. Suggested readings:
25
Nov 13, 2024
Exercises on Java Stream API
You can send your solutions to the lecturer with an email with subject "[AP-24] Solutions to EX 5".
Exercises on Java Stream API: exercises_5.html
Students are invited to bring their laptops. Be sure to have installed:
  • Java SE Development Kit (JDK), version >= 8. Suggested version: JDK 21

Links