-
Notifications
You must be signed in to change notification settings - Fork 129
Description
Continuing discussion started here.
Responding to this
In general, I worry that allowing mutations in responses will destroy their integrity [...]
Yeah, this is an old struggle in software. People have differing opinions what is to be considered a sensible guardrail vs. an overbearing nanny.
In a past life, when dinosaurs still roamed the earth and before the advent of web development which brought an end to the golden age (and basic sanity), I used to write C++ code, which is infamous for handing you loaded guns. In as far as these guns weren't pure footguns, I liked it because essentially it says "I trust you to behave like an adult. In capable hands, this is powerful and can be wielded elegantly. In incompetent hands, it will cause chaos and destruction."
And so the question you too face here is: "Do I protect users from their own stupidity to the best of my abilities (because I know most of them to be bumbling chucklefucks), or do I treat them like adults (of which I know there's only a small sliver)?"
Given your comment of:
I also get the point about trying to forward a readonly array to a third-party API that hasn't typed its inputs as readonly, but that seems to please me and displease me in equal measure.
I suspect that we have a somewhat similar temperament of "Yes, let those who fail to wield the tool properly experience the pain firsthand." - Sadly, in my experience, we are in the minority with this attitude.
"Write software that any idiot can use, and only idiots will use it." is not widely appreciated and more often than not, people create systems that give rise to asshole filters.
So my reply to "irresponsible people might shoot themselves in the foot with mutable returns" is "good, with a bit of luck, they eliminate themselves from the gene pool and the world (or at least my userbase) becomes a bit more sane, one funeral at a time".