14/03/2014
Five Reasons ASP.NET Developers Should Care About Node.js
1. Node is a fast, lightweight means to serve static content + JSON
As browser capabilities and JavaScript VMs have improved over the last several years, we’ve seen a steady movement of “application behavior logic” (not necessarily the same thing as business logic) from the server to the client. Where the traditional approach has been to consume server resources to dynamically generate HTML and push it to the browser (Web Forms, Razor, etc.), in the interest of performance and scale (and continuing comfort with JavaScript as an application platform unto itself) we increasingly offload dynamic UI behaviors to the browser through manipulation of “static” HTML via CSS and JavaScript, backfilled by JSON data from the server. Thus today’s web server has comparatively less work to do than yesterday’s… which makes Node’s lightweight model a potentially attractive alternative to ASP.NET’s more heavyweight, prescriptive model that came of age when server-side rendering was state-of-the-art. Ask yourself… if you’re primarily serving static HTML, CSS, and JavaScript files + JSON data from REST endpoints, do you really need ASP.NET for that?
2. Node is a great choice for teams with extensive JavaScript skills investments
Certainly if you’re a .NET developer then you’ve invested heavily in the Microsoft stack and the requisite skillsets to maximize that. But the days of the monochromatic enterprise are gone, and even we C # diehards have had to (sometimes grudgingly Smile) bolster our JavaScript skills in order to stay current. If your team is staffed with a bunch of JS rockstar-ninja-samauri-megacoders then by all means take a closer look at Node for your next project. The ability to share tribal wisdom, libraries, and best practices across your entire application codebase and team is very powerful. Ironically we’ve been there before in the not-too-distant past… this time it appears we’ll have a different outcome.
3. Node integrates very nicely with Visual Studio
In November 2013 Microsoft released the Node.js Tools for Visual Studio, which do exactly what you’d expect from the name… provide an integrated development and (importantly) debugging experience for Node applications, right inside VS.NET. You get breakpoints, variable values, call stacks, editor niceties, NPM integration (NPM is NuGet for Node, in essence), and more. It’s an alpha release, but very usable. Especially if you’re planning to continue .NET development in addition to exploring Node, I highly recommend it.
4. Node has a burgeoning ecosystem for Windows and .NET integration
As a long-time .NET developer, this has been the most pleasant surprise (and my favorite part) of getting to know Node. There are a handful of Node modules (opt-in extensions and frameworks that augment Node’s core behaviors) that make transitioning from .NET to Node less painful, even comfortable. If you know .NET and you’re getting to know Node, make time for these as well. In no particular order:
iisnode – This module allows you to host Node applications inside IIS on Windows (Node still runs in its own process(es) so it’s not quite “inside”). This conveys several useful advantages to your Node apps… IIS process lifetime management, support for web gardens (important for scaling Node on multi-core machines), integrated security, etc.
httpsys – This is a drop-in replacement for Node’s built-in HTTP stack. It utilizes the kernel-mode http.sys driver in Windows to provide increased performance and kernel-level output caching (among others). Not compatible with iisnode (so, useful for self-hosted Node apps on Windows).
node-sqlserver – A module developed by the Azure team at Microsoft for querying against local or cloud-based SQL Server instances, from within a Node app. Not as wrist-friendly as Entity Framework Smile but certainly gets the job done.
passport-windowsauth – This module provides Integrated Windows authentication for Node applications, similar to the traditional integrated auth experience in ASP.NET. It also does forms-based authentication. It depends upon the passport.js Node authentication module.
TypeScript – Not a Node module per-se, but its worth noting that TS provides a great experience for building and maintaining Node applications. Especially useful for C # devs moving to Node and struggling to build out large-ish codebases.
edge – Edge.js is my favorite module for Node/.NET integration. Edge allows you to call virtually any arbitrary .NET code from within a Node application. Any .NET code you can shoehorn into an async delegate is usable. This is great for integrating with existing .NET code libraries… you can write new Node applications and still leverage valuable core business functionality written in .NET, without having to re-write it in JavaScript! Very powerful stuff. If you’re coming from .NET and going to Node, check it out.
5. Node works great with Windows Azure
Whether you’re talking about IaaS Virtual Machines or PaaS Web Sites or Cloud Services, Node.js deploys easily and runs great on the Azure cloud platform. To help you get started, the Azure folks provide a comprehensive, Node-centric overview on how to target the various platform services like Tables, Queues, Service Bus, etc. Node+Azure isn’t seen too often in the wild (at least in the enterprise arena that Wintellect occupies) but that’s a shame… it’s a very powerful combination. You get the simplicity of the Node app model with the feature set and dynamic performance and scale of a major cloud infrastructure. What’s not to like about that? Oh, and by the way… Microsoft themselves liked Node well enough that they based their initial Azure Mobile Services infrastructure on it (they’ve since implemented a .NET version, as well).