Menu
Proposal would bring records and tuples to JavaScript

Proposal would bring records and tuples to JavaScript

A technical committee has proposed adding new deeply immutable value types to the ECMAScript standard

Credit: Dreamstime

JavaScript would gain record and tuple value types under a proposal before ECMA International, the standards body that oversees the popular programming language for web development.

Records and tuples would introduce two deeply immutable data structures to JavaScript: Record, an object-like structure, and Tuple, an array-like structure. A draft of the plan with ECMA Technical Committee 39, which governs ECMAScript, the standard underlying JavaScript.

Records and tuples, the proposal states, can only contain primitives and other records and tuples. They can be thought of as “compound primitives.”

And by being thoroughly based on primitives, they are deeply immutable. Like objects and arrays, records and tuples support comfortable idioms for construction, use, and manipulation, the proposal states. They are compared by contents rather than by identity.

JavaScript engines might perform certain optimisations on construction, manipulation, and comparison of records and tuples, analogous to how strings are implemented. Records and tuples are intended to be usable and understood with external type system supersets such as TypeScript or Flow.

Currently, userland libraries such as immutable.js implement similar concepts. A previous ECMA proposal for immutable data structures was attempted but abandoned because of complexity and lack of sufficient use cases, the proposal states.

The new proposal introduces significant changes, offering usability advantages over user-land libraries such as the following:

  • Records and tuples are easily introspectable in a debugger
  • No additional branching is needed to write a generic library that consumes immutable and JS objects
  • Use cases are avoided where developers may expensively convert between regular JS objects and immutable structures

Records and tuples interoperate well with objects and arrays. They can be read the same way as objects and arrays. The key difference centers on deep immutability and comparison by value rather than identity. Also, the proposed syntax significantly improves the ergonomics of using Record and Tuple in code.

The most recent version of the ECMAScript specification, version 2020, was adopted in June. It featured capabilities in areas such as module loading and a new BigInt type.


Follow Us

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags javascript

Events

Featured

Slideshows

Meet the Reseller News 30 Under 30 Tech Awards 2020 winners

Meet the Reseller News 30 Under 30 Tech Awards 2020 winners

This year’s Reseller News 30 Under 30 Tech Awards were held as an integral part of the first entirely virtual Emerging Leaders​ forum, an annual event dedicated to identifying, educating and showcasing the New Zealand technology market’s rising stars. The 30 Under 30 Tech Awards 2020 recognised the outstanding achievements and business excellence of 30 talented individuals​, across both young leaders and those just starting out. In this slideshow, Reseller News honours this year's winners and captures their thoughts about how their ideas of leadership have changed over time.​

Meet the Reseller News 30 Under 30 Tech Awards 2020 winners
Reseller News Exchange Auckland: Beyond the myths — how partners can master cloud security

Reseller News Exchange Auckland: Beyond the myths — how partners can master cloud security

This exclusive Reseller News Exchange event in Auckland explored the challenges facing the partner community on the cloud security frontier, as well as market trends, customer priorities and how the channel can capitalise on the opportunities available. In association with Arrow, Bitdefender, Exclusive Networks, Fortinet and Palo Alto Networks. Photos by Gino Demeer.

Reseller News Exchange Auckland: Beyond the myths — how partners can master cloud security
Reseller News welcomes industry figures at 2020 Hall of Fame lunch

Reseller News welcomes industry figures at 2020 Hall of Fame lunch

Reseller News welcomed 2019 inductees - Leanne Buer, Ross Jenkins and Terry Dunn - to the fourth running of the Reseller News Hall of Fame lunch, held at the French Cafe in Auckland. The inductees discussed the changing face of the IT channel ecosystem in New Zealand and what it means to be a Reseller News Hall of Fame inductee. Photos by Gino Demeer.

Reseller News welcomes industry figures at 2020 Hall of Fame lunch
Show Comments