Lang design: building no-prototype arrays

21 views
Skip to first unread message

Conrad Buck

unread,
Apr 19, 2026, 12:09:54 PMApr 19
to v8-dev
Greetings from TC39-land! I'm currently working on a proposal for immutable data structures, and there's a puzzle I'm trying to solve that I was hoping someone with knowledge of engine internals might be able to help me out with. In the spirit of the car talk puzzler, here we go:

I'm hoping to be able to use deeply-frozen no-proto objects and arrays as the language basis for records. The advantage here is that there is no risk of prototype pollution, which is appropriate for a data-only structure such a struct/record is.

While I find it extremely promising that the language already contains these objects and has well-defined semantics for them, the trouble I have is that I can't figure out how to construct them in a reasonable amount of time.

The naive way is like this: `Object.setPrototypeOf([], null)` and it's very, very slow.

Is there any faster way to create these objects? I was hoping that `structuredClone` might let me make one the slow way and make more the fast way, but no it copies a no-proto array into an array-proto array.

`new Array({ __proto__: null })` was another idea I had, but proved similarly fruitless as it sets up the array prototype.

If there was a workaround -- a reasonably performant way to get instances -- a Records feature could be introduced to the language with a performant polyfill, making them usable right away. If not, records would be more like a hard-breaking change. I'd really like to understand which situation we're in!

All the best,
Conrad

Ben Noordhuis

unread,
Apr 20, 2026, 5:34:58 AMApr 20
to v8-...@googlegroups.com
Object.setPrototypeOf(arr,null) or arr.__proto__=null is about as fast
as it gets.

I don't know about "very, very slow" - I get 5 million ops/sec on my
crappy 11 years old laptop. Seems plenty fast?
Reply all
Reply to author
Forward
0 new messages