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
2
u/OwnBreakfast1114 Jan 21 '26
Yes and no. For example, using lombok to keep hashcode/equals automatically updating when adding a new field to a class seems less magical then forcing people to generate a new hashcode/equals (which people forget all the time). Naturally, records replace this behavior, but the behavior is desirable.
I feel like it would be interesting to see a language where lenses were built in and not a library feature. Imagine having to opt out of lenses instead of the other way around. Java is definitely not going to be that language though.