Upgrade to Pro — share decks privately, control downloads, hide ads and more …

NodeJs Addon

Ravi Suhag
September 27, 2014

NodeJs Addon

Extending node with C++ using Node Addons

Ravi Suhag

September 27, 2014
Tweet

More Decks by Ravi Suhag

Other Decks in Programming

Transcript

  1. Ravi Suhag UI/UX and Data Visualisation Consultant at Harvard University

    • Founder - Inspiration Edge, Infoclot • Developer, Designer, Hardware Hacker, Entrepreneur • Winner of 6 National and Global Hackathons in last year • Worked with Harvard University, Govt. of India, hoppr, Indiamart ! @Ravi_Suhag ravisuhag.com [email protected] About the Speaker…
  2. Need to know to start building ? ! • V8

    JavaScript, a C++ library for creating objects, calling functions, etc. • lbuv, C event loop library. • NODE-GYP - Build tool
  3. V8 ! • Implements ECMA-262 • Runs on OSes which

    uses IA-32, x64, or ARM processors • Enables any C++ application to expose its own objects and functions to JS code. e.g. Adobe Flash,Widgets in Apple's Mac OS X, Yahoo! Widgets
  4. libuv • Multi-platform support library with a focus on asynchronous

    I/O. • Developed for use by Node.js • Used by Mozilla's Rust language, Luvit, Julia, pyuv
  5. Is this hassle fruitful ? • I have a C++

    library that I’d like to use and I’m not smart enough or don’t have the time to rewrite it. • CPU heavy apps • Super-secret algorithms. - Not really !
  6. if possible write it in JS … JS ⟷ C++

    boundary is slow to cross ! function() { return Math.floor(133.7 / Math.PI); } ! • native JS ~83,333,333 calls/s • V8 return ~13,333,333 calls/s • V8 async ~1,745,200 calls/s • thread pool ~83,682 calls/s (0.1%) benchmarking by kaefer