A deep-dive into the design of typed object handles in a proposed JavaScript API. Handles are movable pointers into typed data structures that enable zero-allocation iteration loops and serve as 'out pointers' for efficient array construction. The post explores subtle design constraints including nullability, the ability for anyone to move a handle (a potential footgun), and how handles differ from typed objects. Three design alternatives are evaluated: keeping handles with nullability embraced, keeping handles but removing movability, or dropping handles in favor of opaque typed object views. The author ultimately argues for option 1, citing that nullability is already a JS reality, nullable handles enable revocable capability-based memory access, and avoiding allocation is especially important in parallel execution contexts.

18m read timeFrom smallcultfollowing.com
Post cover image
Table of contents
An introduction to handlesSubtle pointsControversial pointsDesign alternativesMy preference
1 Impression