News for hackers. Stuff that matters.
Re:We now consider Moment.js to be a legacy project in maint... by glintik on Tuesday September 15, 2020 @04:08AM (#24478944)
"moment.js: Mutable. Thank you, next."

Mutable is not bad, buddy. You live in mutable world.

Re:We now consider Moment.js to be a legacy project in maint... by japgolly on Tuesday September 15, 2020 @05:55AM (#24479510)
False comparison. We're not creating a copy of the mutable world, we're writing software. Pretty different. Good luck programming in DNA or whatever and knowing that your code does what you want it to do.
Re:We now consider Moment.js to be a legacy project in maint... by bbotond on Tuesday September 15, 2020 @02:47PM (#24485123)
Mutability, in this case, can be pretty unexpected.

Just like you don't expect the expression a + 5 to change the value of a but to return a new number, most people don't expect myDate.add(5, 'days') to change the value of myDate.

I know that moment values are mutable, yet I often forget it while writing code and make dangerous mistakes because of how unnatural it is to see an arithmetic expression that is not immutable.

Re:We now consider Moment.js to be a legacy project in maint... by mywittyname on Tuesday September 15, 2020 @04:58PM (#24486623)
That's totally expected behavior to me.

I would expect to use something like Moment.addDate(date1, 5, 'days') if I wanted a new instance of a date to be returned.

Even in javascript-land, methods like that will have side-effects, yet still return this often just for the sake of method chaining. E.g. date.add(5, 'days).format("%Y-%m-%d") would mutate date, but return the same instance as a convenience.

Re:We now consider Moment.js to be a legacy project in maint... by TheCoelacanth on Tuesday September 15, 2020 @01:14PM (#24483763)
No I don't. I live in an immutable, four-dimensional world /s

These are all just models of the real world, not the reality. The real world can be modeled equally accurately as mutable or immutable, it just depends which properties of the real world you care about modeling.

Re:We now consider Moment.js to be a legacy project in maint... by theon144 on Tuesday September 15, 2020 @04:18AM (#24478989)
Mutable is not bad when necessary, but otherwise I'd say that immutable is generally quite good.