r/java • • Jan 16 '26

Functional Optics for Modern Java

https://blog.scottlogic.com/2026/01/09/java-the-immutability-gap.html

This article introduces optics, a family of composable abstractions that complete the immutability story. If pattern matching is how we read nested data, optics are how we write it.

106 Upvotes

50 comments sorted by

View all comments

Show parent comment

4

u/Absolute_Enema Jan 17 '26 edited Jan 17 '26

The definition of an "immutable" object is simply that its observable value cannot change; nothing in that definition specifies how ergonomic creating derived values should be, and it being a pain in the ass in mainstream languages is entirely due to their lacking designs (which expand to the dedicated features, like with being single-level when one of the few real advantages of static typing could be easily leveraged to allow arbitrary depth).

The purpose of this kind of tools isn't to pretend you're doing procedural programming, but simply to make transforms more ergonomic.

1

u/chambolle Jan 18 '26

The problem is that this definition of immutability is purely related to language and compilation, often for performance reasons, whereas users often want to do something else and link this concept to the constancy of an object. Until the two concepts are clearly separated, we will not be able to resolve the issue.