Re:We now consider Moment.js to be a legacy project in maint...
by winstonewert on Tuesday September 15, 2020 @12:40PM
(#24483288)
You didn't have language enforced immutability. But you still could have convention enforced immutability. If you don't provide apis that mutate your objects and document that mutating is not supported, you get almost all of the benefits of immutability.
Re:We now consider Moment.js to be a legacy project in maint...
by jimmaswell on Tuesday September 15, 2020 @12:04PM
(#24482852)
You can mess with private fields with reflection in other languages too. If someone's bent on bypassing your API you're not going to stop them.
When all your objects are hashmaps you can't really make fields immutable. Even if you wrote getters, someone can just reassign the function reference.
Even if you check your fields in incoming object parameters, somebody can randomly add more fields that you don't know about. Until recently you couldn't stop people from randomly adding fields to your objects
Nowadays JS supports stuff like freeze thaw which makes it easier