Advanced Programming [AP-19]

Code 301AA - 9 Credits


LECTURER

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

Matteo Busi <matteo.busi@di.unipi.it>
Timetable Monday 11-13, Room Fib A1
Tuesday 9-11, Room Fib N1
Thursday 16-18, Room Fib N1
Office hours Friday, 9-11.
Alternatively, to fix a date send an email to <andrea@di.unipi.it>

Course description

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

Announcements


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. During the oral exam the lecturer may ask questions about any of the topics 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.
    In the email proposing the dates for the oral exam (see below) the student has to propose at least three 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 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-19] 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.

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 Functional Programming:

For Object-Oriented programming:


Course Schedule

N.
DATE
TOPIC
SLIDES
NOTES
1
Sep. 16, 2019
Presentation of the course Slides: AP-2019-01.pdf
AP-2019-02.pdf
2
Sep. 17, 2019
Languages and Abstract Machines
Compilation and interpretation schemes
Slides: AP-2019-03.pdf Suggested readings: Chapter 1 of Programming Languages: Principles and Paradigms by Maurizio Gabbrielli and Simone Martini
3
Sep. 19, 2019
Compilation and interpretation schemes (end),
Runtime System (start).
Entry test
Slides: AP-2019-03.pdf
AP-2019-04.pdf, till slide 9.
Suggested readings: Chapter 7: Run-time Enviroments Section 7.1, 7.2 and 7.4.1-2 of "The Dragon Book"

The entry test is intented to evaluate if students have the necessary prerequisites of the course, namely knowledge of concepts of Object-Oriented and Functional programming.

4
Sep. 23, 2019
The Java Virtual Machine, Runtime Data Areas, Multithreading, Dynamic Linking, ...
Slides: AP-2019-04.pdf, till slide 35. 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 13 Edition
Reference documentation: The Java Language Specification, Java SE 13 Edition
5
Sep. 24, 2019
The JVM: linking and loading, verification, initialition and finalization.
The JVM Instruction Set, start.
Slides: AP-2019-04.pdf, all.
AP-2019-06.pdf, till slide 5.
Suggested readings:
Finalization of Class Instances, Section 12.6 of The Java Language Specification, Java SE 13 Edition
6
Sep. 26, 2019
The JVM Instruction Set
Slides: AP-2019-06.pdf, all. Suggested readings: Section 2.11 and Chapter 3 of The Java Virtual Machine Specification, Java SE 13 Edition
Java Code To Byte Code - Part One, by James D. Bloom, http://blog.jamesdbloom.com/JavaCodeToByteCode_PartOne.html
7
Sep. 30, 2019
Room A1
Exercises: Inspecting the JVM
Students are invited to bring their own laptop.
Instructions: exercises_1.html
Files: javaSources_1.zip
Software needed for the exercises:
Please check that the downloaded software works correctly on you computer.
8
Oct. 1, 2019
Software Components: an introduction Slides: AP-2019-07.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.
9
Oct. 3, 2019
Software Components: the Sun approach, JavaBeans Slides: AP-2019-08.pdf Suggested readings:
10
Oct. 7, 2019
Java Enterprise Edition (J2EE) and Enterprise Java Beans (EJB)
Reflection in programming languages
Slides: AP-2019-08-EE.pdf
AP-2019-09.pdf, till page 6.
Suggested readings:
  • Chapter 14 of [COMP], section 14.5
  • 11
    Oct. 8, 2019
    Reflection in Java
    Annotations in Java
    Slides: AP-2019-09.pdf, till page 48 Suggested readings:
    The Java Tutorial on Reflection API, excluding Arrays and Enumerated Types.
    Short tutorial on Java Annotations
    12
    Oct. 10, 2019
    Annotations in Java
    Software Components: the Microsoft way
    Slides: AP-2019-09.pdf, all.
    AP-2019-10.pdf, till page 28.
    Suggested readings:
    The Java Tutorial on Annotations, excluding Arrays and Enumerated Types.
  • Chapter 15 of [COMP], sections 15.1, 15.2, 15.3, 15.4.
  • 13
    Oct. 14, 2019
    Room A1
    Exercises: JavaBeans and Reflection in Java
    • Students are invited to bring their own laptop.
    • To optimize the lab activity, students may read the Oracle JavaBeans Tutorial
    Instructions: exercises_2.html
    Files: javaSources_2.zip
    Software needed for the exercises:
    Please check that the downloaded software works correctly on your computer.
    14
    Oct. 15, 2019

    The .NET Framework, Delegates in C#
    Slides: AP-2019-10.pdf, all.
    Suggested readings:
  • Chapter 15 of [COMP], sections 15.11 and 15.12.
  • Short tutorial on Delegates in C#
  • 15
    Oct. 17, 2019
    Frameworks and Inversion of Control Slides: AP-2019-11-Frameworks-IoC.pdf, till page 35. Suggested readings:
    16
    Oct. 21, 2019
    Room A1
    Exercises: JavaBeans and Reflection in Java
    • Students are invited to bring their own laptop.
    • To optimize the lab activity, students may read the Oracle JavaBeans Tutorial
    We propose to continue the exercises of the last time, possibily addressing also the two new exercises added to the end.
    Instructions: exercises_3.html
    Software needed for the exercises:
    Please check that the downloaded software works correctly on your computer.
    17
    Oct. 22, 2019
    On Designing Software Frameworks Slides: AP-2019-11-Frameworks-IoC.pdf, all
    AP-2019-12-DesigningFrameworks.pdf, till page 21.
    Suggested readings:
    18
    Oct. 25, 2019
    • On Designing Software Frameworks (cont.)
    • Polymorphism
      • A classification
      • Overloading &Amp; Coercion
      • Inclusion polymorphism &Amp; Overriding
      • Explicit parametric polymorphism: Templates in C++.
    Slides:
    AP-2019-12-DesigningFrameworks.pdf, all
    AP-2019-13-Polymorphism.pdf (Polymorphism)
    AP-2019-14-Cpp-Templates.pdf (C++ templates), till page 7
    Suggested readings:
    19
    Oct. 28, 2019
    Universal Parametric Polymorphism:
    C++ Templates and Java Generics
    • C++ templates
    • Java Generics
    • Bounded type parameters
    • Generics and inheritance: invariance, covariance and contravariance
    Slides: AP-2019-14-Cpp-Templates.pdf (C++ templates) all
    AP-2019-15-JavaGenerics.pdf (Java Generics), till page 19.
    Suggested readings:
    20
    Oct. 29, 2019
    • Java Generics: Type erasure, Wilcards
    • The Standard Template Library for C++
    Slides: AP-2019-15-JavaGenerics.pdf (Java Generics), all.
    AP-2019-16-STL.pdf (STL), till page 18.
    Suggested readings:
    21
    Oct. 31, 2019
    The Standard Template Library for C++
    Introduction to Functional Programming
    • Historical origins
    • Main concepts
    • Language families: LISP, ML, Haskell
    Slides: AP-2019-16-STL.pdf (STL), all.
    AP-2019-17-Func.pdf, till page 12.
    Suggested readings:
    Students are invited to install the Glasgow Haskell Compiler and Interpreter (GHCI) downloadable from https://www.haskell.org/platform/
    22
    Nov. 4, 2019
    • Core concepts on Haskell, lazy evaluation
    • The lambda-calculus: syntax and beta-reduction
    • Church Booleans, Pairs and Numerals
    Slides:
    AP-2019-17-Func.pdf, all.
    AP-2019-18-Lambda.pdf, till page 10.
    Suggested readings:
    23
    Nov. 5, 2019
    More on lambda-calculus and on Haskell
    • Arithmetics on Church Numerals
    • Fixpoint operator and recursion
    • Evaluation orders
    • Call by need in Haskell
    • List comprehension
    • Algebraic Data Types
    • Higher-order functions and combinators
    Slides: AP-2019-18-Lambda.pdf, till page 16
    AP-2019-19-MoreFunc.pdf, till page 16
    Suggested readings:
    Nov. 7, 2019
    There will be no lesson on Thursday, November 7
    24
    Nov. 11, 2019
    Aula A1
    Exercises on Functional Programming in Haskell.
    Students are invited to bring their own laptop.
    Instructions: exercises_4.html 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

    25
    Nov. 12, 2019
    On efficiency in functional languages
    Tail recursion optimization
    Type classes in Haskell
    Slides:
    AP-2019-19-MoreFunc.pdf, pages 18-25
    AP-2019-20-TypeClasses.pdf, till page 18.
    Suggested readings:
    Nov. 12, 2019
    Presentation of programming assigments on NetBeans, JavaBeans and Reflection in Java. First programming assignment [Suggested deadline: November 30, 2019]

    26
    Nov. 14, 2019
    Type classes, Constructor Classes and Monads in Haskell
    Slides: AP-2019-20-TypeClasses.pdf, all.
    AP-2019-21-Monads.pdf, till page 21.
    Suggested readings:
    Nov. 18, 2019
    Lesson canceled because of weather alert.
    27
    Nov. 19, 2019
    The IO Monad in Haskell
    Lambda expressions in Java 8
    Slides: AP-2019-21-Monads.pdf, all
    AP-2019-22-JavaLambdas.pdf, till page 6.
    Suggested readings:
    28
    Thursday
    Nov. 21, 2019
    Lambda expressions in Java 8
    The Stream API in Java 8
    Slides: AP-2019-22-JavaLambdas.pdf, all
    AP-2019-23-JavaStreams.pdf
    Suggested readings:
    29
    Friday
    Nov. 22, 2019 - 16-18
    Aula A1
    Exercises on Functional Programming and Type Classes in Haskell.
    Students are invited to bring their own laptop.
    Old exercises: exercises_4.html
    New exercises: exercises_5.html
    An excellent tutorial on Haskell: http://learnyouahaskell.com
    30
    Monday
    Nov. 25, 2019
    Aula A1
    Exercises on the Stream API and on partial functions in Java 8.
    Instructions: exercises_6.html
    Auxiliary file: people.csv
    Suggested readings:
    Use of Optional in Java, http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html
    31
    Tuesday
    Nov. 26, 2019
    The RUST programming language AP-2019-24-Rust.pdf Suggested readings:
  • Introduction to Rust, slides by Haozhong Zhang
    Reference documentation of Rust:
  • https://doc.rust-lang.org/book/foreword.html
  • 32
    Thursday
    Nov. 28, 2019
    Scripting Languages Slides: AP-2019-25-Scripting.pdf Suggested readings:
    33
    Monday
    Dec. 2, 2019
    Exercises on the Stream API and on partial functions in Java 8 (cont.).
    Instructions: exercises_6.html
    Auxiliary file: people.csv
    Suggested readings:
    Use of Optional in Java, http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html
    34
    Tuesday
    Dec. 3, 2019
    Introduction to Python
    • Basic and Sequence Datatypes
    • Dictionaries
    • Control Structures
    • List Comprehension
    • Function definition
    Slides: AP-2019-26-Python.pdf Suggested readings:
    Thursday
    Dec. 5, 2019
    Lesson canceled Students are strongly encouraged to take part to the event Theses presentation Event for StudEntS, see http://theses.di.unipi.it/
    35
    Monday
    Dec. 9, 2019
    Invited Lecture by Mario Fusco Comparing different concurrency models on the JVM Slides: https://www.slideshare.net/mariofusco/comparing-different-concurrency-models-on-the-jvm
    36
    Tuesday
    Dec. 10, 2019
    More about Python
    • Function definition
    • Positional and keyword arguments
    • Functions as objects
    • Higher-order functions
    • Combinators vs. list comprehension
    • Decorators
    • Namespaces and Scopes
    • Object Oriented programming in Python
    Slides: AP-2019-27-Python-OOP.pdf, till page 31.
    37
    Thursday
    Dec. 12, 2019
    • 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
    • Style guidelines for writing scripts
    AP-2019-27-Python-OOP.pdf, all.
    AP-2019-28-GIL-etAl.pdf
    38
    Friday
    Dec. 13, 2019
    Aula A1 - 16-18
    39
    Monday
    Dec. 16, 2019
    40
    Tuesday
    Dec. 17, 2019

    Links