PCP Lecture

PCP Lecture

Introduction

The programming concepts and paradigms PCP convey the basic for functional programming and modern java programming. The Clojure language [1] is used to teach functional programming approaches. The focus is on immutability, functions as first-class citizens, and parallel programming. We analyze later how far it is possible to use these techniques in the modern Java language.

Slides and reference literature are in English and published under Slides and Literature.

Description

\$2/3\$ of the lecture is the presentation of new concepts. \$1/3\$ of the lecture is used to discuss exercise solutions and support the students in the application of the concepts.

Modern Java

The modern Java [2, 3, 4, 5] lectures are:

Lecture Content Details

Lecture 1

Algebraic Data Types

  • Records

  • Sealed types with interfaces, abstract classes, classes, and records

  • Pattern matching and deconstruction in the conditional statements if and switch

  • Implement the visitor pattern with a functional approach

Lecture 2

Lambdas and Streams

  • Single abstract method SAM interface and abstract class

  • Custom intermediate and final operations with gatherers and collectors

  • Tricks with type inference. An example of a functional builder is discussed.

  • Functional Programming with Java

Lecture 3

Modules

  • Module concepts and declarations

  • Create and deploy services

  • Modernize Java legacy applications and migrate them to a module structure

Lecture 4

Structured Concurrency with Loom

  • Virtual threads

  • Executors

  • Structured concurrency

  • Do we still need asynchronous programming or asynchronous frameworks?

Interested readers can explore further functional programming [6] and Java modules [7].

Clojure

The emphasis is on the functional aspects of Lisp and Clojure.

The students should be able to appreciate the more powerful constructs available in Clojure in comparison of Modern Java. At the same time, they should understand how to map most Clojure functional approaches to Java and the limits of these solutions.

References

[1] S. D. Halloway, Programming Clojure. 2012 [Online]. Available: https://www.amazon.com/dp/B07BN4C92X

[2] S. Harrer, J. Lenhard, and L. Dietz, Java By Comparison. Pragmatic Bookshelf, 2018 [Online]. Available: https://www.amazon.com/dp/B07CLFTVZS

[3] J. Bloch and N. Gafter, Java™ Puzzlers. Addison-Wesley Professional, 2005 [Online]. Available: https://www.amazon.com/dp/032133678X

[4] J. Bloch, Effective Java, Third. Addison-Wesley Professional, 2017 [Online]. Available: https://www.amazon.com/dp/B078H61SCH

[5] K. Henney, 97 Things Every Java Programmer Should Know. O’Reilly Media, Incorporated, 2019 [Online]. Available: https://www.amazon.com/dp/B088P8GV8X

[6] V. Subramaniam, Functional Programming In Java Harnessing The Power Of Java 8 Lambda Expressions. The Pragmatic Programmers, 2014 [Online]. Available: https://www.amazon.com/dp/B0CJL7VKFL

[7] S. Mak, Java 9 Modularity. O’Reilly Media, 2017 [Online]. Available: https://www.amazon.com/dp/1491954167