I just want an understanding for 2 questions around the same topic: "fields". The first question is simple:
- If objects on a prototype object had been treated as copy-on-write to any portion of that object since long before this proposal, would
classdata declarations have been placed on the prototype instead of "fields"?
Put anther way, is the object on the prototype problem (foot gun) the primary (if not sole) reason behind fields? There have been claims that this proposal is just following the pattern laid down by developers using ES6 classes. While that may be true, the reasoning isn't the best given that programmers are going to take the simplest solution to a problem, and in this case, the problem was that ES6 classes didn't provide for declarative data.
What I'm trying to get from this first question is why we're walking down this awkward path in the first place. If the relationship between
class data declarations and the prototype foot-gun is compared to the relationship between private-fields and Proxy objects, it can easily be said that where in one case, TC39 is willing to allow a newly created problem to exist because its "just an expansion of the scope of an existing problem", with the other the zeal to avoid expanding the scope of one existing problem is leading to the expansion of the scope of several other problems of lesser renown.
The second question is more technical:
2. What approaches, if any, were raised to directly tackle the foot-gun in question, and why were they not acceptable?
TC39 is a group of very bright people, so it would be completely outside my expectations for no one in the committee to make such a suggestion. If I'm capable of raising at least 3 viable solutions by myself, it must certainly be the case that similar solutions were tried and defeated before settling on a design with so many trade-offs for developers.
My only intent with these questions is to understand the line of thinking that went into this design. I will likely always be of the mindset that this design does not represent TC39's best work, and is not the best design that could be created either. However, I don't wish to argue over such things. I merely wish to understand how we got here.