I like working in Scala quite a bit, but always wince at the "instead of using threading primitives consider this 10x more exotic immutable approach" lead-in. Does anyone here really work that way?
Never sure why people talk about concurrency as the number one reason to use immutable structures.
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.
I do, and immutability of a data type has more benefits than just concurrency. Copy-on-write immutable data structures gives the developer confidence when they pass it around. However, I sometimes still leverage mutable structures in self-contained internal situations due to performance and ergonomics.
The dangers of mutability in the context of concurrency are well known and people would do well to read "Java Concurrency in Practice", a book that recommends for all classes to be defined as immutable (with final fields to get the JMM benefits), unless you have really good reasons for not doing it.
Not sure what threading primitives you're talking of, but it depends. In general Scala has very sane abstractions for dealing with concurrency.
What matters is the complexity of the systems built out of these things. Threading primitives are simpler to understand in isolation, but lead to non-deterministic behavior.
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".