11# ABI Stability
22
33## Introduction
4- An Application Binary Interface (ABI) is the compiled version of an Application
5- Programming Interface (API). That is, the headers files describing the classes,
6- functions, data structures, enumerations, and constants used to enable an
7- application to perform a desired task correspond by way of compilation to a set
8- of addresses and expected parameter values and memory structure sizes and
9- layouts with which the provider of the ABI was compiled.
4+ An Application Binary Interface (ABI) is a way for programs to call functions
5+ and use data structures from other compiled programs. It is the compiled version
6+ of an Application Programming Interface (API). In other words, the headers files
7+ describing the classes, functions, data structures, enumerations, and constants
8+ which enable an application to perform a desired task correspond by way of
9+ compilation to a set of addresses and expected parameter values and memory
10+ structure sizes and layouts with which the provider of the ABI was compiled.
1011
1112The application using the ABI must be compiled such that the available
1213addresses, expected parameter values, and memory structure sizes and layouts
1314agree with those with which the ABI provider was compiled. This is usually
1415accomplished by compiling against the headers provided by the ABI provider.
1516
16- Since the ABI provider and the ABI user may be compiled at different times with
17- different versions of the compiler, a portion of the responsibility for
18- ensuring ABI compatibility lies with the compiler. Different versions of the
19- compiler, perhaps provided by different vendors, must all produce the same ABI
20- from a header file with a certain content, and must produce code for the
21- application using the ABI that accesses the API described in a given header
22- according to the conventions of the ABI resulting from the description in the
23- header. Modern compilers have a fairly good track record of not breaking the
24- ABI compatibility of the applications they compile.
17+ Since the provider of the ABI and the user of the ABI may be compiled at
18+ different times with different versions of the compiler, a portion of the
19+ responsibility for ensuring ABI compatibility lies with the compiler. Different
20+ versions of the compiler, perhaps provided by different vendors, must all
21+ produce the same ABI from a header file with a certain content, and must produce
22+ code for the application using the ABI that accesses the API described in a
23+ given header according to the conventions of the ABI resulting from the
24+ description in the header. Modern compilers have a fairly good track record of
25+ not breaking the ABI compatibility of the applications they compile.
2526
2627The remaining responsibility for ensuring ABI compatibility lies with the team
2728maintaining the header files which provide the API that results, upon
@@ -40,17 +41,18 @@ changes that are introduced in the headers the project provides. As a result,
4041the Node.js project has adopted [ semantic versioning] ( https://semver.org/ ) .
4142This ensures that the APIs provided by the project will result in a stable ABI
4243for all minor and patch versions of Node.js released within one major version.
43- In practice, this means that a Node.js native addon compiled against a given
44- major version of Node.js will load successfully when loaded by any Node.js
45- minor or patch version within the major version against which it was compiled.
44+ In practice, this means that the Node.js project has committed itself to
45+ ensuring that a Node.js native addon compiled against a given major version of
46+ Node.js will load successfully when loaded by any Node.js minor or patch version
47+ within the major version against which it was compiled.
4648
4749## N-API
4850Demand has arisen for equipping Node.js with an API that results in an ABI that
49- remains stable across multiple Node.js versions. The motivation for creating
50- such an API is as follows:
51+ remains stable across multiple Node.js major versions. The motivation for
52+ creating such an API is as follows:
5153* The JavaScript language has remained compatible with itself since its very
52- early days, whereas the ABI of the engine executing the JavaScript changes with
53- every major version of Node.js. This means that applications consisting of
54+ early days, whereas the ABI of the engine executing the JavaScript code changes
55+ with every major version of Node.js. This means that applications consisting of
5456Node.js packages written entirely in JavaScript need not be recompiled,
5557reinstalled, or redeployed as a new major version of Node.js is dropped into
5658the production environment in which such applications run. In contrast, if an
@@ -78,10 +80,9 @@ adopted by native addons.
7880
7981To these ends Node.js has introduced N-API in version 8.6.0 and marked it as a
8082stable component of the project as of Node.js 8.12.0. The API is defined in the
81- headers [ ` node_api.h ` ] ( https://github.com/nodejs/node/blob/master/src/node_api.h )
82- and [ ` node_api_types.h ` ] ( https://github.com/nodejs/node/blob/master/src/node_api_types.h ) ,
83- and provides a forward-compatibility guarantee that crosses the Node.js major
84- version boundary. The guarantee can be stated as follows:
83+ headers [ ` node_api.h ` ] [ ] and [ ` node_api_types.h ` ] [ ] , and provides a forward-
84+ compatibility guarantee that crosses the Node.js major version boundary. The
85+ guarantee can be stated as follows:
8586
8687** A given version * n* of N-API will be available in the major version of
8788Node.js in which it was published, and in all subsequent versions of Node.js,
@@ -97,11 +98,16 @@ the addition of a package written purely in JavaScript.
9798
9899N-API is versioned because new APIs are added from time to time. Unlike
99100semantic versioning, N-API versioning is cumulative. That is, each version of
100- N-API conveys the same meaning as a minor version in the semver system.
101- Additionally, new N-APIs are added under an experimental flag. This means that,
101+ N-API conveys the same meaning as a minor version in the semver system, meaning
102+ that all changes made to N-API will be backwards compatible. Additionally, new
103+ N-APIs are added under an experimental flag to give the community an opportunity
104+ to vet them in a production environment. Experimental status means that,
102105although care has been taken to ensure that the new API will not have to be
103- modified in an ABI-incompatible way in the future, it has not yet been proven in
104- production to be correct and useful as designed and, as such, may undergo
105- ABI-incompatible changes before it is finally incorporated into a forthcoming
106- version of N-API. That is, an experimental N-API is not covered by the forward
107- compatibility guarantee.
106+ modified in an ABI-incompatible way in the future, it has not yet been
107+ sufficiently proven in production to be correct and useful as designed and, as
108+ such, may undergo ABI-incompatible changes before it is finally incorporated
109+ into a forthcoming version of N-API. That is, an experimental N-API is not yet
110+ covered by the forward compatibility guarantee.
111+
112+ [ `node_api.h` ] : ../../src/node_api.h
113+ [ `node_api_types.h` ] : ../..src/node_api_types.h
0 commit comments