Comments (5)
Thanks @Xuyv - this is an interesting idea. One downside of doing this is that every NAPI call becomes an indirect call, which has perf implications. Can you describe a concrete scenario where the current NAPI approach does not work for you? Note that at Node-Interactive, @aruneshchandra demoed a single NAPI-enabled module, compiled once, and then executed with node v0.10, v0.12, v6, and node-chakracore
from abi-stable-node.
@digitalinfinity I think it has no problem for NAPI module compiling once and then being executed on different versions of node now. The thing that concerns me is that once the api changes( like, add one more function argument in napi_set_return_value) in new NAPI, the old compiled modules will not work.
If function pointers are stored in env, we may control api changes more elegantly and easily. For example, (just an idea)store different functions in env for new versions of NAPI when native module are loaded. And it's opaque to developers.
from abi-stable-node.
Ah, I understand now- so in this world, the add-on would query node for the environment and ask for a particular version of the API, and then proceed to call it? Interesting. In that case, would node need to preserve all the old versions of the APIs, so that the modules could still call this?
One other way this can be solved is, NAPI APIs can never be removed - it's a purely an additive interface- so new APIs being added would not break modules coded against the old API since those APIs would continue to ship. Thoughts? @mhdawson was the plan for the NAPI interface planned to be additive?
from abi-stable-node.
I have also thought that using a function table could make migration easier and have raised it with the overall team in the past. Other platforms like Java use one and it makes it possible to support multiple versions of the API, and have modules request the version that they were compiled against.
The downside as mentioned is the performance overhead due to indirect calls. If we had lots of free cycles I'd have us build with/without a function table and do some performance comparisons but I don't think we'll have the cycles in the short term. We should discuss this one of our upcoming weekly meetings to get more input/discussion so that we can document our decision/rational on this point.
In terms of the specific questions, in general I do see it as being additive. We'll still need some
sort of versioning so that a module can figure out what version its being compiled against so that
it can figure out which function are available.
from abi-stable-node.
This was discussed at several VM summits and we decided to stick to our current approach
from abi-stable-node.
Related Issues (20)
- Ask for review of node-serialport Node-API port - https://github.com/serialport/node-serialport/pull/2305/files HOT 2
- Drive towards full coverage HOT 5
- Discuss Node-API addition https://github.com/nodejs/node/pull/41329#issuecomment-1015667899 HOT 1
- Regular hang in Running test 'typed_threadsafe_function/typed_threadsafe_function_sum' HOT 1
- Node-API v9 HOT 7
- Better coverage of node-api in Youtube HOT 13
- Node-API add-on build HOT 4
- Add list of non C language bindings to Node.js doc HOT 10
- Document how to check for memory leaks in addon/default leak. HOT 4
- Electron 21 breaks api compatability with some modules HOT 9
- Get contacts for each of the runtimes supporting Node-API HOT 8
- What's new in the Node-API and node-addon-api world? - 2023 version HOT 20
- Can references be shared between different modules/envs? HOT 3
- Improve score on OpenSSF scorecard HOT 8
- Consider changing the license for examples to MIT HOT 2
- Tracking issues for V8 changes needed HOT 1
- Help with node-sqlite3 performance HOT 3
- What's new in the Node-API and node-addon-api world? - 2024 version HOT 3
- Discuss reverting nogc commits HOT 1
- Warn/print message when NAPI_EXPERIMENTAL is used in a build HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from abi-stable-node.