Re:Immutable Data
by c_crank on Monday June 26, 2023 @10:49AM
(#36480314)
Most relevant and non obscure languages support a const feature of some kind.
[ Parent
| on HN ]
It's too little.
There's no language I know of where slapping 'const/final' in front of a field or a function will free you of the burden of considering whether you can safely share it (with the exception of primitives).
If I have a final field of Set<AllowedUsers>, I can't return it, because the caller can insert a new user.
Speaking as someone working in the CRUD Java salt mines, I've never had an issue with sharing variables like this that allegedly makes imperative programming fundamentally broken and unproductive. Scoping and any basically functional program layout does 95% of the work for you.