3 ms·
> I guess it's an obvious way to design it. It's an obvious way to design it... if you start with explicitly declared properties in your language. For JavaScr
by mraleph 11y ago
> I guess it's an obvious way to design it.
It's an obvious way to design it... if you start with explicitly declared properties in your language.
For JavaScript a state-of-art for a long time was more like this:
+-------+
| *---+-> hashtable for properties
+-------+
| |
~~~~~~~~~ various metadata (e.g. prototype chain)
~~~~~~~~~
| |
+-------+
all properties mixed together, all stored in a hash table, etc.
The non-obvious thing to design here is how you escape from the realm of hashtables into the realm of something both more compact and faster to work with (given certain statistical assumptions about the properties of the code).
- evincarofautumn 11y agoMoreover, if you’re doing the naïve thing, hashtables per se aren’t even particularly good for object properties—most objects are small, so an RB-tree or even linear search performs nicely.