0

I'd like to have all the advantages of Node.js for writing web-based applications at my disposal. However, I'm aware that its model isn't great for running computational intensive DSP functions. I was skimming the documentation and found that there was an area on addons.

I guess my question is this: if I wrote my DSP functions in C++ (or brought it in from somewhere else), and incorporated them into my Node.js application, how much of a slowdown would I experience? I'm under the impression that since I'm making calls to a shared library, I shouldn't experience any slowdown. Any insight on this would be great.

1
  • Did you have any thoughts or questions about my answer? Commented Jul 19, 2014 at 7:52

1 Answer 1

1

You don't have to build a binary addon to interoperate with your C++ code. Perhaps you could turn the C++ code into a command line tool?

You can then use the child_process module in node to spawn a process of your DSP tool and use some kind of IPC (inter-process communication) such as Unix sockets to communicate between node and c++.

This way you eradicate the need for too much C++ glue code.

Child Process: http://nodejs.org/api/child_process.html

Net (for sockets): http://nodejs.org/api/net.html

It would only be as slow as your individual components. Node wouldn't block while waiting for data from your C++, so can be doing other things (responding to HTTP requests etc).

Another option for IPC is to use a message passing library such as zeromq.

zeromq c++ bindings: http://zeromq.org/bindings:cpp

zeromq node binding: http://zeromq.org/bindings:node-js

Sign up to request clarification or add additional context in comments.

2 Comments

Sorry it took me so long to approve this answer. I eventually went with socket communication. Thanks for providing some easier alternatives!
@Paul no worries, glad you sorted it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.