0

I have a node.js website (db is mongodb), one of the 2 requirements are a very complex function that calculates a "shopper score" based on several factors which is queried in the database. Second requirement is an affinity basket analysis which also requires some complex algorithm calculation.

My preference was to write them in C# and pack it as a dll. I saw this post but its too old - Using a .NET DLL in Node.js / serverside javascript

Is there a latest technology/interface which allows node.js javascript to call a .net dll file and get a return value back? The site is hosted on windows server.

OR

is it better to write the algorithm in node.js javascript function?

UPDATING the post based on comments:

There are couple of reasons for thinking about .net dll.

  1. Security- there are cases where we have to deploy/host the node website on client's server. JS code is open, atleast the dll will be compiled (understand its not unbreakable but atleast it provides some level of obfuscation).

  2. We have an existing dll which receives messages, processes and updates database, Looking at long term roadmap, we thought the dll could trigger updates to active users based on certain

Thank you!

Community
  • 1
  • 1
user3658423
  • 1,904
  • 5
  • 29
  • 49
  • but why? If you started with node.js, why c#? What can't JS do that C# can? Sounds like a very strange design decision. – Andrey Jul 22 '14 at 00:11
  • 1
    It looks like the library linked in an update to the question you referred to as too old had its last update two months ago. https://github.com/tjanczuk/edge – ctlacko Jul 22 '14 at 00:13
  • I agree with Andrey. I'm sure JS <-> C# *can* be done... buy why? – Mike Bell Jul 22 '14 at 00:14
  • @Andrey OP is probably thinking node.js is bad for computation heavy processes. OP, here is an article that provides an analysis of using node for a computationally complex task. http://neilk.net/blog/2013/04/30/why-you-should-use-nodejs-for-CPU-bound-tasks/ – ctlacko Jul 22 '14 at 00:22
  • @ctlacko if you don't mess up with code so that heavy optimizations are not possible JS is not much slower then C#. In my experience language itself is rarely a bottleneck. – Andrey Jul 22 '14 at 00:26
  • @Andrey. Agreed, language is rarely a bottleneck. OP should carefully consider the benefits of keeping it simple before adding this node <-> c# complexity to his/her project. – ctlacko Jul 22 '14 at 00:32
  • @Andrey - There are couple of reasons. 1. Security- there are cases where we have to deploy/host the node website on client's server. JS code is open, atleast the dll will be compiled (understand its not unbreakable). 2. We have an existing dll which receives messages, processes and updates database, Looking at long term roadmap, we thought the dll could trigger updates to active users based on certain criterias.. – user3658423 Jul 22 '14 at 00:53
  • @user3658423 .net dll are not just not unbreakable, you can recover the code within few clicks. 2 - Makes sense – Andrey Jul 22 '14 at 13:47
  • Node.js modules can also be compiled and wrap [C or C++ objects](http://nodejs.org/api/addons.html#addons_addons). There are some solutions for C#, but I have not tried these .. for example: [Edge.js](http://tjanczuk.github.io/edge/). As an alternative to wrapping your DLL at a low level (which will add more software maintenance debt in order to keep the Node/C# glue interfaces up to date), you could also consider providing an API for the Node app to talk to a C# backend. See also: [Integrating Node.js with a C# DLL](http://java.dzone.com/articles/integrating-nodejs-c-dll). – Stennie Jul 28 '14 at 10:22

0 Answers0