Replies: 1 comment 12 replies
-
Thanks a lot for that. I'm completely aware that Hyrum's Law will kick in. That's why I suggested standardizing an undocumented behaviour. By any chance, would you feel like drafting a JEP here ? |
Beta Was this translation helpful? Give feedback.
12 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Spun off from #47 (reply in thread)
JavaScript learned the hard way that "implementations are not required to return values in any specific order" is not really a tenable position for a language with multiple implementations, because in practice if a sufficiently popular implementation does provide results in a predictable order then users come to rely upon that behavior (cf. Hyrum's Law) and less popular implementations are forced to follow suit, resulting in a de facto predictable order that eventually gets added to the specification anyway. I am only aware of two ways around this: either specify a predictable order up front, or specify that order is intended to be unpredictable in any particular implementation (such that an implementation which sorted entries or preserved source order would be nonconforming, which is basically impossible to ensure with conformance tests).
I absolutely understand the desire to let the use of predictable vs. unpredictable ordering be unspecified and therefore support maximum convenience for building an implementation, but my experience is that it just doesn't work out in the long run.
Accordingly,
keys
andvalues
and a potentialitems
should all be specified to return results in a particular order. Using source order is possible and would be acceptable, but I'm more partial to specifying a static algorithm by which keys must be sorted (e.g., lexicographically by Unicode code point) because that minimizes potential security vulnerabilities derived from leveraging information about insertion order.Beta Was this translation helpful? Give feedback.
All reactions