2 ms·
This. Javascript engines have to do stuff like https://mathiasbynens.be/notes/shapes-ics https://mathiasbynens.be/notes/shapes-ics to assume many objects will h
by erik_seaberg 7y ago
This. Javascript engines have to do stuff like https://mathiasbynens.be/notes/shapes-ics https://mathiasbynens.be/notes/shapes-ics to assume many objects will have the same key names and types and create an optimized class layout, with some kind of expensive fallback if anyone ever randomly stores a key or value that violates the assumption. They can't even be sure you'll always be doing integer math (unless you resort to bit masking a la asm.js). Hinting (like __slots__ in Python) might have helped some.
- discreteevent 7y agoThis was one of the main motivations for writing dart. The V8 implementers were tired of having to write these kinds of hacks. Even though dart was initially a dynamically typed language, the shape of the objects was stable.