Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js native extension vs. pure js module

Tags:

node.js

I'm writing a new node.js component. I write it from scratch - no existing assets to reuse. What are some of the considerations for building a native extension vs. a pure js module?

like image 803
Yaron Naveh Avatar asked May 29 '26 23:05

Yaron Naveh


1 Answers

You should try to write pure js modules. First they are a lot easier to write and maintain. Second they are cross-platform. Third, which I think is also pretty important you will probably have no memory leaks when you write your extensions in pure javascript.

When you have finished the pure javascript implementation and the performance is desired/OK I don't think you should write native extension. Only try this when the performance is subpar.

Also I believe they are changing the complete infrastructure to write native extension and will use gyp instead?

like image 95
Alfred Avatar answered May 31 '26 15:05

Alfred



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!