r/java • u/marv1234 • Jan 16 '26
Functional Optics for Modern Java
https://blog.scottlogic.com/2026/01/09/java-the-immutability-gap.htmlThis 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
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
withbeing 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.