| ▲ | pdimitar an hour ago | |||||||
But that's still not a function of the syntax per se; Java has no immutability encoded in its runtime, hence it does not offer it as a syntax either. | ||||||||
| ▲ | hibikir 29 minutes ago | parent [-] | |||||||
Scala has no immutability encoded in its runtime either (as it's the same as Java), but yet syntactically it's immutable in practice. Will the JRE technically allow a val to be edited through some third party thread inspecting your code and messing with memory? Sure. But it's not a reasonable fear in any real world environment, where I cannot remember, in 15+ years of professional scala, a case where anything I expected to be immutable (everything) to be mutated under me. Nowadays people using in in an FP style don't even think of the physical threads, as green thread libraries are taking care of all the scheduling. So focusing on the runtime's guarantees doesn't seem like a practicality focused argument to me. | ||||||||
| ||||||||