3 ms·
> I think the mutable Date object in javascript was a mistake. I'm not much of a JS guy, but isn't mutable objects the norm, not the exception? Over in Java l
by mrkeen 2y ago
> I think the mutable Date object in javascript was a mistake.
I'm not much of a JS guy, but isn't mutable objects the norm, not the exception? Over in Java land we have the mutable ArrayList and the mutable HashSet etc.
> Maybe I'll see the light when I manage to comprehend what a monad is.
That's not going to happen.
First you need to see a problem (e.g. a mutable object being a mistake.)
Then you need to see a range of solutions.
Then the best solution needs to be a particular Thing.
Then that Thing needs to resemble other different Things which solve other problems.
If those different solutions resemble one another enough, you can put them under a common interface Monad.
But if there is no problem with a mutable AST object or a mutable Date object, then you won't even consider the solutions. A monad won't solve the problem you don't have.
- recursive 2y agoMutable and immutable objects are both common. In Java, ArrayList is mutable, but String is not. If you concatenate strings, it makes a new string. It never changes the existing one. This maps pretty well to peoples' intuitions when using strings. If you have a reference to a string, its' contents can never change. You can assign a new string to your variable, but that's different. In JS, the contents of a Date object can change. This is widely regarded to be a mistake, and I agree with that.