nodejs / nodejs/node

Remove FFI type aliases while it's still experimental

Open
#64,848 7 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature request ffi
Dominant language
JavaScript
Stars
122k
Forks
37.3k
Avg merge
4d 2h
Merged PRs (30d)
283

Description

What is the problem this feature will solve?

node:ffi was introduced with synonyms for the same types

i8, int8
u8, uint8, bool, char
i16, int16
u16, uint16
i32, int32
u32, uint32
i64, int64
u64, uint64
f32, float
f64, double
pointer, ptr
string, str
buffer
arraybuffer

While this may be convenient for folks that are familiar with the different names, it also adds mental overhead - developers need to confirm if 'char' and 'u8' mean the same thing or are subtly different.

There were a few bugs that are kindof related to this

  • when ffi.types.FLOAT_32 was added it's value was float32 which wasn't a supported alias, so now there's three ways to spell float 32.
  • buffer and arraybuffer are also synonyms but are different lines in the docs
  • char is listed on the same lines as u8 and bool but it is not a synonym (it varies by platform)

cc @nodejs/ffi

What is the feature you are proposing to solve the problem?

We should remove each synonym and keep one spelling for each distinct type.
I'm not opinionated on which spelling we prefer, I think the uint8 style agrees with ffi.types and the access helpers (getUint8).

We should do this now while the module is experimental. WE can always add more names in the future, but removing them after the module is stable is harder.

What alternatives have you considered?
  • we could do nothing and live with the synonyms
  • we could deprecate and print a warning when the non-preferred aliases are used

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the node:ffi entry point and inventory the type aliases, ffi.types names, access helpers, and documentation references. The preferred spelling is not decided in the issue, so review the existing API conventions before proceeding. Done means each distinct type has one spelling and the related docs and behavior consistently reflect the removal.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.