Hacker News new | ask | show | jobs
by bastawhiz 616 days ago
> You don't strictly need known/consistent types, but it sure helps, since otherwise everything needs to be 8 bytes.

Arguably that's worse than what the runtime is able to do today already with hidden classes.

> I don't think a way to read into and out of ArrayBuffers is possible

If you know all the types and only allow structs and primitives, you could use relative pointers to encode the 2nd+ references to structs that appear more than once in the encoded object. You'd need a StructArray for efficient arrays, but a linked list would encode pretty compactly. But you're very right.