Functional Programming In Java 22 - Understanding the Building Blocks of FP


A conference talk about how Java can be used for purely functional programming, and the fundamentals of purely functional languages.

Conferences
JavaDay Istanbul 2024

Intended audience Developers with intermediate coding skills

Summary
Functional programming promises huge advantages, but it still remains a mystery to many. In this talk, I’ll focus on explaining key concepts such as lazy, immutability, currying, composition, and also explain topics such as ADTs, morphisms, lambda calculus and advanced pattern matching in Java 22.

This talk is about the practical use of functional programming in an object-oriented language like Java. We know that it’s very difficult to write pure code in a functional style in Java because the language lacks important elements such as immutability, laziness, higher order types, stronger type inference, better function composition and currying, tail-call optimization, and stronger pattern matching. These deficiencies lead to a lower degree of abstraction, poorer decomposition, and we cannot express ourselves as elegantly as we would like. So why should we care about functional programming in Java?

The answer lies in the fact that by learning techniques from other languages, you also become a better developer in the language you normally use. Java 21 now supports “Unnamed Patterns and Variables”, and with the existing support for Sealed Interfaces and Record Patterns, some Java code can now be written much simpler and more expressively.

This is an informal look at functional programming, the aging java.util.function library, and the latest additions in JDK22 that bring Java closer to other JVM languages such as Kotlin. The talk is well suited for those who have not engaged much in functional programming, but who wish to get a bit of inspiration.

Language English

Video JavaDay Istanbul 2024

Slides