Re:Speeding up the JavaScript ecosystem – one library at a time
by brundolf on Wednesday November 30, 2022 @01:34PM
(#33805356)
I'm very surprised the property ordering would matter. Seems like the JS engine itself could easily fix that, no? Silently re-order the properties to fit its own optimization
Do you have a source for the above info? (both because I'm a little skeptical of some parts of it, but also because I'd love to learn more about this topic and I've had trouble finding concrete info in the past)
Re:Speeding up the JavaScript ecosystem – one library at a time
by hajile on Wednesday November 30, 2022 @06:00PM
(#33809249)
JS specifies that the order keys are added makes a difference. For this reason, entering them in two different ways is a fundamentally different, non-interchangeable object type.
This is polymorphic because union types are polymorphic.
It's super easy to make non-optimized arrays and objects this way. Any use of optional object properties also immediately leads to polymorphism too. I doubt you can find ANY significant TS codebase where this isn't used pervasively. Even if we remove the `?`, it can still be polymorphic because the TS compiler doesn't reorder object properties when compiling.