Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Choosing a node.js library with pure js vs C++ add on implementation

Choosing a node.js library with pure js vs C++ add on implementation

Problem

What are the pros and cons of choosing a Pure js Library over a library with some C++ code ? ex. timezone-js(pure js) over node-time(cpp addon) for date with timezone support.

PS: App needs to be hosted in Heroku

Thanks

Problem courtesy of: gkr

Solution

Assuming that the libraries are functionally similar, I can think of a couple pros and cons:

C++ Pros

  • Generally faster than a pure JS implementation (this may not always be true--always test yourself)
  • Ability to do CPU-intensive work asynchronously in the thread pool

C++ Cons

  • May not compile on all platforms, usually happens when the addon requires some third-party libs
  • May be harder to debug/fix problems (depending on your level of expertise in C++/V8)

If you would prefer to use the C++ addon but are concerned about it not running on Heroku, create a small test app that uses it and deploy it. If you would prefer to use the JS lib but are concerned about speed, you'll really need to do your own real-world performance testing to see if it's actually an issue.

Solution courtesy of: Michelle Tilley

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Choosing a node.js library with pure js vs C++ add on implementation

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×