Nodejs vs SignalR: 为什么我们需要服务器端的 javascript?

自从我知道 Node.js 以来,我一直是它的粉丝。但是今天我发现了 信号 R,它为 ASP.NET 提供了一种可供选择的异步-可伸缩-实时模型。

据我所知,Node.js 相对于 SignalR 的主要优势是客户机-服务器之间共享代码(另一个优势应该是它是跨平台的) ,而 SignalR 的主要优势是一个更加成熟的框架和更好的工具(IDE)支持。所以我想知道: 如果 SignalR 在这里,我们还需要 Windows 上的 Node.js 吗?我不知道 Node.js 有什么优点吗?

51873 次浏览

SignalR is a viable alternative to Socket.IO and Node.js. There are other reasons to use javascript on the server however.

  1. It flattens the stack. Almost any website these days has to have javascript on the browser, and if you use it on the server as well, you can cut one language out of the batch that you'll have to be proficient in.

  2. Message passing is very natural. JSON Everywhere! Especially combined with a document database which uses JSON, all message passing just becomes JSON objects. This makes reduces the amount of message brokering that has to happen throughout the system.

  3. It's not Microsoft. I personally love what Microsoft has done for the development community. They make fantastic tools and one of the best frameworks and languages around. That being said, some people just love to hate Microsoft.

  4. Cost. There are many good ways to get Microsoft tools for free or very cheap (Express editions and Biz Spark). There is still a higher cost associated with working with Microsoft tools. I believe this cost is worth the productivity gains in most instances, but not everyone agrees.

In addition to the above, there is still the story going around that you can't scale long polling requests on IIS due to the threading model. This has some truth to it, but with good code design, and some server tweaks, you can mostly get around these problems.