Advanced Programming [AP-20]

Code 301AA - 9 Credits


LECTURER

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

Laura Bussi <laurabussi@live.it>
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 <andrea@di.unipi.it>

Page permanently under construction...

Course description

See: https://esami.unipi.it/esami2/programma.php?c=47430&aa=2020&cid=69&did=13

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 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-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: https://meet.google.com/onu-wwrg-edq. 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

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. 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.
2
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.
3
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
4
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"
5
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 http://blog.jamesdbloom.com/JVMInternals.html
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.
6
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
7
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, http://blog.jamesdbloom.com/JavaCodeToByteCode_PartOne.html

Proposed Exercises: Inspecting the JVM

Instructions: exercises_1.html
Files: javaSources_1.zip
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)
8
Oct. 1, 2020
Exercises: Inspecting the JVM
Instructions: exercises_1.html
Files: javaSources_1.zip
 
9
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.
10
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:
11
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.
12
Oct. 9, 2020
Reflection in Java
Annotations in Java (start)
Slides:
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
13
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.
14
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.
15
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:
16
Oct. 21, 2020
Inversion of Control and Dependency Injection in Software Frameworks Slides: AP-2020-10.pdf, all
Suggested readings:
17
Oct. 22, 2020
.NET Core and Microsoft Strategies Invited lesson by Prof. Antonio Cisternino Video
18
Oct. 23, 2020
On Designing Software Frameworks Slides: AP-2020-11.pdf, all
Suggested readings:
19
Oct. 28, 2020
Polymorphism:
  • A classification
  • Overloading & Coercion
  • Inclusion polymorphism & Overriding
  • Explicit parametric polymorphism: Templates in C++.
Slides:
AP-2020-12.pdf
AP-2020-13.pdf, till page 12.

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

Suggested readings:
20
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: https://godbolt.org/
(a site for exploring compiled code)
Some C++ code: listings.cpp

Suggested readings:
21
Oct. 30, 2020
  • Java Generics
  • The Standard Template Library for C++
Slides: AP-2020-14.pdf (Java Generics), till page 15.
AP-2020-15.pdf
An overview of the STL.
Suggested readings:
22
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 https://www.haskell.org/platform/
23
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
Slides:
AP-2020-16.pdf, all.
AP-2020-17.pdf, till page 13.
Suggested readings:
24
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:
25
Nov. 11, 2020
Exercises on Functional Programming in Haskell.

We will try to have some interactions with you exploting https://repl.it/: 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 https://www.haskell.org/platform/
An excellent tutorial on Haskell: http://learnyouahaskell.com

26
Nov. 12, 2020
Type classes in Haskell Slides:
AP-2020-19.pdf.
Suggested readings:
27
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]

28
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:
29
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:
30
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:
31
Nov. 25, 2020
The RUST programming language Slides: AP-2020-23.pdf, till page 33 Suggested readings:
32
Nov. 26, 2020
Other aspects of RUST
Scripting Languages
Slides: AP-2020-23.pdf
AP-2020-24.pdf.
Suggested readings:
33
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, http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html
34
Dec. 2, 2020
Introduction to Python
  • Basic and Sequence Datatypes
  • Dictionaries
  • Control Structures
Slides: AP-2020-25-Python.pdf, till page 62. Suggested readings:
35
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:
36
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.
37
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]

Links