Advanced Programming [AP-21]

Code 301AA - 9 Credits


LECTURER

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

Laura Bussi <laurabussi@live.it>
Virtual classroom Advanced Programming Team
Timetable Tuesday 9:00 - 10:45
Thursday 9:00 - 10:45
Friday 16:15 - 18:00
Office hours Only by appointment sending an email to <andrea@di.unipi.it>. We will meet in this virtual room: https://meet.google.com/onu-wwrg-edq

Page permanently under construction...

Course description

See: https://esami.unipi.it/esami2/programma.php?c=51769&aa=2021&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 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 // send an email to the lecturer at latest 5 days before the date of the oral exam 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-21] 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 either in presence, or online as virtual meetings of the channel ORAL EXAMS of the Advanced Programming Microsoft Team. The student can choose the language (either English or Italian).


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 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. 14, 2021
Presentation of the course Slides: AP-2021-01.pdf
AP-2021-02.pdf, till page 19
The video of the lesson is accessible on Microsoft Team. If you cannot access it, ask the lecturer.
Poll on Doodle for choosing office hours
2
Sep. 16, 2021
Design patterns
Syntax, Semantics and Pragmatics
Programming languages and Abstract Machines (tbc)
Slides: AP-2021-02.pdf, all
AP-2021-03.pdf till page 19.
Suggested readings: Chapter 1 of Programming Languages: Principles and Paradigms by Maurizio Gabbrielli and Simone Martini
3
Sep. 17, 2021
Compilation and interpretation schemes
Runtime System
The Java Virtual Machine, up to Runtime Data Areas, ...
Slides: AP-2021-03.pdf all.
AP-2021-04.pdf till slide 16 (JVM Runtime Areas).
Suggested readings: Chapter 7: Run-time Enviroments Section 7.1, 7.2 and 7.4.1-2 of "The Dragon Book"
4
Sep. 21, 2021
The Java Virtual Machine: Runtime Areas
Slides: AP-2021-04.pdf, till slide 32. 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. 23, 2021
The JVM: verification, initialition and finalization.
The JVM Instruction Set, start.
Slides: AP-2021-04.pdf, all.
AP-2021-05.pdf, till slide 9.
Suggested readings:
Java Code To Byte Code - Part One, by James D. Bloom, http://blog.jamesdbloom.com/JavaCodeToByteCode_PartOne.html
6
Sep. 24, 2021
The JVM Instruction Set, end.
Slides: AP-2021-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, http://blog.jamesdbloom.com/JavaCodeToByteCode_PartOne.html
7
Sep. 28, 2021
Software Components: an introduction Slides: AP-2021-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.
8
Sep. 30, 2021
Exercises: Inspecting Java bytecode and the JVM
You can upload you solutions in the folder EXERCISES-01, in the File tab of the Team of the course. All your files have to be collected in a single folder with name YYYY-MM-DD-YOURNAME, for example 2021-09-30-CORRADINI

Proposed Exercises: Inspecting the JVM

Instructions: exercises_1.html
Files: javaSources_1.zip
Note:During the lesson the ZIP archive did not contain the right Java files for the exercises: I apologize for that. I updated the ZIP archive. It would be great if you could do or re-do the third exercise on WrongQueue.java
For this lesson, please be sure to have installed:
Any other combination of versions is fine, provided that the three software are compatible and that the JDK has version larger than or equal to 8. Please check that the downloaded software works correctly on you computer.
9
Oct. 1, 2021
Software Components: the Sun approach, JavaBeans
Reflection in programming languages
Slides: AP-2021-07.pdf
AP-2021-08.pdf, up to page 7.
Suggested readings:
10
Oct. 5, 2021
Reflection in Java
Annotations in Java (start)
Slides:
AP-2021-08.pdf, till slide 49.
Suggested readings:
The Java Tutorial on Reflection API, excluding Arrays and Enumerated Types.
The Java Tutorial on Annotations.
11
Oct. 7, 2021
Exercises: Java Beans, Reflection and Annotations
You can upload you solutions in the folder EXERCISES-02, in the File tab of the Team of the course. All your files have to be collected in a single folder with name YYYY-MM-DD-YOURNAME, for example 2021-09-30-CORRADINI
Instructions: exercises_2.html
Suggested activity:
To get ready for the exercises we will propose, practice with Netbeans and with the use/development of Java Beans reading the Oracle JavaBeans Tutorial
12
Oct. 8, 2021
Polymorphism:
  • A classification
  • Overloading & Coercion
  • Inclusion polymorphism & Overriding
  • Explicit parametric polymorphism: Templates in C++.
Slides:
AP-2021-09.pdf
AP-2021-10.pdf, till page 10.
Suggested readings:
13
Oct. 12, 2021
Universal Parametric Polymorphism:
C++ Templates and Java Generics
  • C++ templates
  • Java Generics
  • Bounded type parameters
Slides: AP-2021-10.pdf, till page 10. (C++ templates) all
AP-2021-11.pdf (Java Generics), till page 8.

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

Suggested readings:
Java Generics tutorials:
14
Oct. 14, 2021
Generics and inheritance: invariance, covariance and contravariance
Covariance of Arrays in Java
Limitations of Generics.
Slides: AP-2021-11.pdf (Java Generics), all.

Suggested readings:
Covariance and Contravariance in C# https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/covariance-contravariance/
15
Oct. 15, 2021
The Standard Template Library for C++ Slides: AP-2021-12.pdf
An overview of the STL.
Suggested readings:
16
Oct. 19, 2021
Introduction to Functional Programming
  • Historical origins
  • Main concepts
  • Language families: LISP, ML, Haskell
  • Core concepts on Haskell
Slides: AP-2021-13.pdf. Suggested readings:
Students are invited to install the Glasgow Haskell Compiler and Interpreter (GHCI) downloadable from https://www.haskell.org/platform/
17
Oct. 21, 2021
  • 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
Slides: AP-2021-14.pdf Suggested readings:
18
Oct. 22, 2021
More on Haskell
  • List comprehension
  • Algebraic Data Types
  • Higher-order functions and combinators
Slides: AP-2021-15.pdf, till page 16. Suggested readings:
19
Oct. 26, 2021
Type classes in Haskell Slides:
AP-2021-16.pdf, till page 33.
Suggested readings:
20
Oct. 28, 2021
Proposed exercises on fuctional programming with Haskell
You can upload you solutions in the folder EXERCISES-03, in the File tab of the Team of the course. All your files have to be collected in a single folder with name YYYY-MM-DD-YOURNAME, for example 2021-09-30-CORRADINI
Instructions: exercises_3.html
The lesson of Thursday, October 28, will be dedicated to these exercises.
21
Oct. 29, 2021
Type inference
Constructor Classes and Monads in Haskell
Slides:
AP-2021-16.pdf, all. AP-2021-17.pdf, till page 16.
Suggested readings:
22
Nov. 2, 2021
Constructor Classes and Monads in Haskell
Input-Output in Hakell: the IO Monad
Slides:
AP-2021-17.pdf, till page 50.
Suggested readings:
23
Nov. 4, 2021
Type (un)safety in Haskell: unsafePerformIO
Lambda expressions in Java 8
Slides: AP-2021-17.pdf, all. AP-2021-18.pdf, till slide 17. Suggested readings:
24
Nov. 5, 2021
The Stream API in Java 8 Slides: AP-2021-18.pdf, all. AP-2020-21.pdf. Suggested readings:
Nov. 9, 2021
Presentation of the programming assigments on JavaBeans and Reflection in Java. First programming assignment [Suggested deadline: December 5, 2021]

25
Nov. 9, 2021
Software Components: the Microsoft way (start) Slides: AP-2021-20.pdf, till slide 43 (excluding 7-20). Suggested readings:
Chapter 15 of [COMP], sections 15.1, 15.11, 15.12.
Proposed exercises on Type Classes in Haskell and on the JAVA Stream API
Solutions can be uploaded in folder EXERCISES-0405, in the File tab of the Team of the course. All your files have to be collected in a single folder with name YYYY-MM-DD-YOURNAME, for example 2021-11-25-CORRADINI
Exercises on Type Classes in Haskell: exercises_4.html
Exercises on Java Stream API: exercises_5.html
Auxiliary file: people.csv
The lesson of Thursday, November 18, will be dedicated to these exercises.
26
Nov. 11, 2021
Software Components: the Microsoft way (end)
Delegates in C#
Slides: AP-2021-20.pdf, all (excluding 7-20). Suggested readings:
27
Nov. 12, 2021
Frameworks and Inversion of Control Slides: AP-2021-21.pdf Suggested readings:

.NET Core and Microsoft Strategies
Invited lesson by Prof. Antonio Cisternino held on Oct. 22, 2020
28
Nov. 16, 2021
On Designing Software Frameworks Slides: AP-2021-22.pdf Suggested readings:
29
Nov. 18, 2021
Proposed exercises on Type Classes in Haskell and on the JAVA Stream API
Solutions can be uploaded in folder EXERCISES-0405, in the File tab of the Team of the course. All your files have to be collected in a single folder with name YYYY-MM-DD-YOURNAME, for example 2021-11-25-CORRADINI
Exercises on Type Classes in Haskell: exercises_4.html
Exercises on Java Stream API: exercises_5.html
Auxiliary file: people.csv
The lesson of Thursday, November 18, will be dedicated to these exercises.
30
Nov. 19, 2021
The RUST programming language Slides: AP-2021-23.pdf Suggested readings:
Reference documentation on Rust:
31
Nov. 23, 2021
A brief overview of Scripting Languages

Introduction to Python (I)

Slides: AP-2021-24.pdf
AP-2021-25.pdf, till slide 41.
Suggested readings:
32
Nov. 25, 2021
Introduction to Python (II)
  • Dictionaries
  • Control Structures
  • List Comprehension
  • Function definition
  • Functions as objects
  • Higher-order functions
  • Namespaces and Scopes
Slides: AP-2021-25.pdf, all.
AP-2021-26.pdf till slide 25.
Suggested readings:
33
Nov. 26, 2021
More about Python
  • Closures
  • Object Oriented programming in Python
  • Special Methods
  • Multiple Inheritance
  • Name mangling
  • Iterators and generators
  • Typing in Python
Slides: AP-2021-26.pdf till slide 46. Suggested readings:
34
Nov. 30, 2021
  • Garbage collection in CPython
  • The Global Interpreter Lock
  • Miscellaneous criticisms to Python
  • Browsing the Python documentation
AP-2021-26.pdf, all.
34
Nov. 30, 2021
Proposed exercises on Python
Solutions can be uploaded in folder EXERCISES-06, in the File tab of the Team of the course. All your files have to be collected in a single folder with name YYYY-MM-DD-YOURNAME, for example 2021-11-30-CORRADINI
Exercises on Python: exercises_6.html
Auxiliary file: anagram.txt

Dec. 2, 2021
On Thursday, December 2 there will be no lesson. However the lecturer will ve available on Teams from 9:00 to 10:45 for any question about the First Programming Assignment or the Exercises proposed during the course.
35
Dec. 3, 2021
  • "Just in time" to understand, a presentation by Gabriele Pappalardo on Just-In-Time compilation
  • Presentation of the Second Programming Assignment
Link to slides: "Just in time" to understand
Dec. 6, 2021
Second programming assignment [Suggested deadline: January 8, 2022]

Links