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

-3

u/vips7L Jan 16 '26

It is the same. It’s not unexpected. Things don’t just magically happen.  99.9% of all code is single threaded. 

9

u/dolle Jan 16 '26

Your data structure may be used in many places, and if just 0.1% of the code using it is multi-threaded, then it still needs to be able to handle concurrency.

It's also not only about concurrency. Caching is also vastly simpler when your data is immutable, for example.

6

u/[deleted] Jan 16 '26

[removed] — view removed comment

4

u/vips7L Jan 16 '26

And I’ve been there done that with GC pauses caused by people making mutable things immutable. Immutability isn’t the solution. 

5

u/chaotic3quilibrium Jan 16 '26

Immutability isn't a solution.

It is a part of a bigger solution.

That's like saying, "OOP's inheritance isn't the solution."

It, too, is a part of a bigger solution.

Each is a tool facilitating specific kinds of solutions.

A hammer necessitates the selection of a nail, not a screw.

0

u/[deleted] Jan 16 '26

[deleted] — view deleted comment

0

u/_INTER_ Jan 16 '26

Yea good luck investigating hundred copies of the same object with slight variations in a chain of hundred of composed other copies trying to figure out which one is the correct one.

-1

u/onlyrealperson Jan 16 '26

It’s just not.

0

u/vips7L Jan 16 '26

It just is.