Edge.js: Let. NET and Node.js code both blanket

Source: Internet
Author: User

With the Edge.js project, you can run both Node.js and. NET code in one process. In this article, I will discuss the motives behind this project and describe the basic mechanisms that edge.js provides. A few edge.js scenarios will then be explored to help you develop node.js programs in these scenarios.

Why do you use Edge.js?

While many applications can only be written with node.js, in some cases they need to combine the benefits of both node.js and. Net. For several reasons, you want to use it in a program. NET and node.js:.net frameworks and NuGet packages provide a rich functional ecosystem that complements node.js and NPM modules; you might want to reuse some ready-made. NET components in a node.js program Or you might want to use multithreaded CLR to run CPU-intensive computing, which is by no means a single-threaded node.js, or you might prefer to use the. NET Framework and C # rather than using C + + Write native Node.js extensions to access operating system mechanisms that have not yet been exposed through node.js.

Once you decide to use node.js and. NET in your program, you must separate the node.js and. NET components with process barriers and establish some form of interprocess communication mechanism, such as http:

Edge.js provides another way to build a heterogeneous system like this. It allows you to run both Node.js and. NET code in a single process, and provides an interoperability mechanism between V8 and the CLR.

With Edge.js, you can run Node.js and. NET in one process without splitting it into two processes, which has two main benefits: better performance and lower complexity.

Performance tests for a scenario show that the edge.js request from Node.js to C # is 32 times times faster than the same request sent over HTTP between two processes. Compared to two processes and interprocess communication channels, handling only a single process significantly reduces the complexity of the deployment and maintenance you need to address.

. NET Welcome Node.js

Next I'll explain the key concepts of edge.js with a basic example of sending a request from Node.js to C #.

Line 1th introduces the Edge module installed in advance from NPM. Edge.js is a native node.js component. The special thing about Edge.js is that when it is loaded, it starts hosting the CLR within the Node.exe process.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.