-
Notifications
You must be signed in to change notification settings - Fork 0
Proposed switch from neon to node-bindgen #7
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
Comments
Yes, sounds great. I'm totally in favor of choosing something according to your intuition, and now the only thing I'm thinking is that I regret calling all these packages |
Agreed that the generic naming approach is the way to go. Should I get a PR together to enact the switch to |
Yes and yes! :) I also feel like renaming ssb-neon |
Great! I'll start right away :) Somehow I didn't know about |
Another thing I'd like to prototype before doubling down on node-bindgen is compiling to Android and iOS. It was a headache to extend Neon to mobile and in the process I also built supporting libraries such as neon-load-or-build. I expect that moving to node-bindgen would give similar headaches. I don't doubt it's possible, theoretically node-bindgen should work on Android and iOS with nodejs-mobile, we just need to try it out and fix issues until it works. |
Leaving this here for future reference: infinyon/node-bindgen#114 |
Since you're developing on an rpi4, it's already correctly compiling for aarch64, right? |
That's correct. I've been using my default toolchain for compilation (without any issues):
|
Housekeeping I'm closing this issue. Spoiler-alert: we ended up switching to node-bindgen (#8). |
Background
While scanning through the latest release of This Week in Rust on Saturday, I noticed this blog post: Sending tuples from Node to Rust and back. That introduced me to an alternative crate for generating bindings for Node: node-bindgen.
Yesterday I converted our batch verification & validation code to use
node-bindgen
and I have to say I like it a lot. It provides neat type conversion for JS values and stays out of my way so I can write idiomatic Rust code. I'm presenting some pro's and con's of the two approaches here so we can reach a decision together. I'll say up-front that I've in favour of node-bindgen.Code Samples
A quick comparison of the verification function signatures, argument parsing and module exporting behaviour:
Neon (what we're currently using)
node-bindgen
The secret sauce here is the
#[node_bindgen]
attribute (seen above the function signature definition) which automatically generates conversion code for Node and Rust to pass values back and forth.Note: there's a slight difference here because this function is actually expecting an array of stringified values.
neon
Pros:
Cons:
node-bindgen
Pros:
Cons:
Conclusion
Without meaning to be rude,
neon
feels to me like it was written by JS devs whilenode-bindgen
feels like it was written by Rust devs. Maybe that's an unkind thing to say but withneon
I feel like I'm constantly working against the API.In terms of performance, I have not yet seen a difference, so the key advantage of the switch here is maintainability of our code and improved developer experience. If I showed the
node-bindgen
validation code to another Rust dev they'd understand it instantly and could get to work implementing new features or making changes (no need to learn the esoterica ofneon
).The text was updated successfully, but these errors were encountered: