Edge.js Combines Node.js with .NET
Created by Tomasz Janczuk, Edge.js is intended in part to make it easier for developers to maximize their Node.js usage without resorting to non-CLR languages like C/C++. Edge.js' approach provides several benefits, including the ability to execute CPU-bound calcualtions in .NET without blocking Node.js' event loop. It also allows using C# to write Node.js extensions to access Windows-platform specific features without resorting to the use of C/C++.
The connection between node.js an Edge.js is seamless and bilateral: node.js can call .NET methods and .NET code can call Node.js. Edge.js can compile C# source at run time or it can be pre-compiled before Edge.js starts.
InfoQ was fortunate to have the opportunity to discuss the project with Janczuk and talk about his future plans for Edge.js:
InfoQ: Any specific motivations for the project beyond simply desiring to provide connection between C# and Node.js?
Janczuk: "Edge.js aspires to provide developers with a choice of technology that best suites the task at hand at a finer scope than the entire application. Edge.js is based on the premise that everything can be done in either node.js or .NET, but specific things are often better done with one of them. Until now the choice between node.js and .NET was a choice that developers had to make at the scope of the entire application. With Edge.js, developers have the option of using .NET or node.js for aspects of their application for which particular technology makes more sense."
InfoQ: The .NET examples all seem to be C#, does Edge.js require C#? And if so, would language support be broadened to other .NET platform languages?
Janczuk: "Edge.js allows .NET code to be integrated with a node.js application either by specifying a pre-compiled CLR assembly, or by including .NET source code within the node.js application. Edge.js supports any CLR language that can generate a pre-compiled assembly with a Func<object,Task<object>> delegate. When literal .NET code is included in the node.js application, edge.js currently only supports C#."
InfoQ: What are the goals for the project over the next 6-12 months?
Janczuk: “Edge.js plans to remain a small component with relatively few fundamental concepts that enable interop between .NET and node.js in-process. Scenario-specific functionality, for example access to MS SQL, writing to Windows Event Logs, or access to X.509 certificate store, is expected to evolve as new modules that depend on edge.js rather than by expanding the scope of edge.js itself. Some notable plans for edge.js itself include support for Mono, compiling CLR languages other than C# and hosting node.js within a .NET process.”
InfoQ: Given your professional employment at Microsoft as an Engineer, will this remain an independent project or at some part would it become a formal part of Microsoft tooling?
Janczuk: "While Microsoft has a track record for embracing open source technologies, there are no plans currently for edge.js to become part of any Microsoft product."
Edge.js is an open source project released under version 2 of the Apache License. Janczuk has an overview available on the project's website that includes code samples for those seeking more information.
Russ Danner May 03, 2015