-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docs: Further improvements to Addon section, specifically numeric and binary IO #8269
Comments
I am making use of this code so far:
I could do with opinions on if this is the best way to do it. |
Does this work correctly with subarrays, e.g. |
@addaleax No, it's not working properly with subarrays. I created a subarray with the code you provided. The only item in that subarray is I have merged the typed array code into master on https://github.com/metabench/addone/blob/master/addone.cc Suggestions or code fixes to handle subarrays would be very much appreciated. Thanks for pointing me towards finding this bug. |
The current best code that I have, which takes account of subarrays, is as follows:
I don't fully understand how it works, and I am hoping to get good advice on it and for it or something better to be established as the best-practice way of doing IO of Typed Array data when not using nan (https://github.com/nodejs/nan). It's possible that advances made in understanding the IO of different data types between node and C++ could be useful for the nan project, and it's also possible that code from within nan has patterns which are of use in documenting how to do things when not using nan. |
Well, Lines 32 to 41 in da0651a
|
Yes, it does give an idea on how to tackle this, but it's making use of some quite advanced C++ concepts, or at least ones I don't fully understand. Please correct me if I'm wrong, but it's a template definition, and that the convention is to use capital letters when naming them. I've not made them myself in my C++ programming, but have used them with NAN. I can't see exactly where I could make use of |
I think you’re understanding everything correctly, yes! Just so no confusion comes up, the I’m not actually suggesting that you need to include
Hmm. I’m not disagreeing, this is a problem, but maybe the question is not what should be documented, but where that documentation should be. Handling Also, there’s |
The main issue is that the v8 documentation is not very approachable. It's basically auto-generated from I think the best bet is to put some pressure on the v8 team to improve it, rather than have node take over the responsibility (which isn't feasible since features can still change drastically in the future). Hopefully it won't take too long. Better documentation is key to widespread adoption. I know I would enjoy seeing more node addons used creatively in high performance applications. Honestly, I don't feel like |
I think the V8 team is kind of aware that their documentation is not optimal. If you want to see something improved in an open source project, it’s always better to spend time yourself on improving things than to “put pressure” on someone.
Are you asking for inclusion of the |
I thought V8 was funded and developed by Google, which is why I added 'put pressure' part. I didn't intend to be derogatory. I will look into helping them with the documentation! I'm not at all proposing an inclusion of nan into node core. I meant that it might be better (for high performance applications) developing addons without using nan, hence the need for better v8 documentation. |
It is. :) |
Closing, but feel free to re-open or comment if you feel like the issue has not been adequately addressed. |
Asking about IO between C++ and JavaScript has been a common theme to the issues I have opened. I have had some questions answered before, and prompted some discussions on what kind of documentation is best. See:
#883
#2977
#3296
I have done some work on examples that show the interface between C++ and node.js by internally performing the simple operation of adding one to a number. I now wish to make it output a Float64Array, but have not seen example code of how to do it, nor got it work when I tried to make one in C++ using V8.
Here is the beginnings of some code which could be of use within the node documentation to demonstrate the outputting of Typed Arrays from C++: https://github.com/metabench/addone/tree/typed_arrays
In order to help developers make use of C++ for more numerically or computationally intensive tasks, it's worth improving the documentation (lowering the learning curve) for the most efficient types of IO between C++ and JavaScript.
The text was updated successfully, but these errors were encountered: