News for hackers. Stuff that matters.
Re:We now consider Moment.js to be a legacy project in maint... by kqr on Tuesday September 15, 2020 @02:29AM (#24478429)
> Until very recently it was impossible to make objects immutable in JS. Even now its really only done using third party libraries.

There's a big difference between "literally impossible to mutate" (only important in the most security-critical contexts) and "designed around immutability as the default" (which is what is desired in most of the real world.)

The former not being possible is not a reason to exclude the latter.

Re:We now consider Moment.js to be a legacy project in maint... by throwaway189262 on Tuesday September 15, 2020 @02:46AM (#24478517)
With JS, until recently, it was nearly impossible to design immutable API's. Everything takes JSON based objects which have no field accessors. All the objects underneath are just hashmaps with string keys.

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

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.
Re:We now consider Moment.js to be a legacy project in maint... by Ndymium on Tuesday September 15, 2020 @03:05AM (#24478601)
Object.freeze() has been available since IE 9, Firefox 4, Chrome 6 etc. Not really "recently" in web terms.