Where I've used this in real code is via circe-optics (json parsing). An example: https://stackoverflow.com/questions/36724068/how-to-parse-a-...
It allows you to work with deep data structures in a safe immutable way.
Scala is a nice language for working with data, the standard library, techniques such as lenses and ecosystems such as Spark all contribute to this.
import monocle.macros.Lenses
@Lenses
case class Foo(bar: Int)
val x = Foo(1)
assert(Foo.bar.get(x) == 1)The main reason is that your code is less buggy and easier to read and understand as your code base gets larger. You never have to worry if that variable is being modified somewhere else in your codebase because it simply isn’t.
Not sure what threading primitives you're talking of, but it depends. In general Scala has very sane abstractions for dealing with concurrency.
I've only used optics in a couple small situations, but even if I find some big downside, I'll still be open to "exotic immutable approaches".
Your comment has typos too :-)