@dkf said in Going to the Google's walled garden with Go:
Yet another use case for mutation is when you're deserializing an object. You need the object to exist to deserialize into it. (I'm not 100% sure how Java and C# actually solve this.)
At best, it's a use-case. Clearly Java and C# can manage without it. I'd guess that it's because they are able to create a blank instance without calling the normal constructor behind it, and then populate the fields based on the previously serialised data blob. A sort of "extrospection" (or maybe "interspection"), if you like (I don't, because it's a made-up word, but a reasonable one...), where an object on the outside (the deserialiser) is able to grope the data structures of the new object, in the same way that the object can analyse itself by introspection.
Well, that's how I'd build it, anyway.
((Digression: C++ can't do any of this automatically, which some would frame as a weakness, but I'm not 100% convinced that it isn't a strength, because it makes sure that the programmer thinks(1) about what's going on.))
(1) Heaven forbid that we hope that programmers think about what they are doing ...)