Update: Restricting subclassing support in built-in methods – Data
Yulia Startsev & Matthew Gaudet, Mozilla
Reminder:
This proposal is about trying to remove some of the forms of subclassing of built-in types in the JS language
Type I: minimal support (Not Proposed for Removal)
Type II: subclass instance creation in built-in methods
Type III: customizable subclass instance creation in built-in methods
Type IV: delegation to property lookups in built-in methods
Proposal:
“We propose to remove support for Type II, Type III, and Type IV subclassing, and only keep Type I.”
Hypothesis:
Experiment: Counting actual subclassing on the web
Bug 1896505 - Add use-counter telemetry for subclassing types
Annotate our code to report when a document actually performs subclassing.
Our Results:
We Are Surprised by these Results.
Submission Date | 2024-08-22 |
Array Type II | 6.9211% |
Array Type III | 16.5238% |
ArrayBuffer Type III | 0.0000% |
SharedArrayBuffer Type III | 0.0000% |
TypedArray Type II | 0.0001% |
TypedArray Type III | 0.2482% |
RegExp Type III | 11.2277% |
RegExp Type IV | 16.0279% |
Promise Type II | 21.3367% |
Promise Type III | 17.2540% |
Concurrence with previous results:
New Results:
Possible Forward Futures
We think that it is worthwhile to attempt to remove ArrayBuffer support. Unused functionality nearby sensitive code like ABs seems like asking for trouble.
We should still adopt a rationale that future built-in subclassing beyond Type I should be strongly discouraged.
Careful Design
This is yet more evidence that design of JS has to be considered carefully: Unshipping errors ranges from incredibly hard to outright impossible.