10

I do quite a bit of ASP.NET work (C#, MVC), but most of it is typical web development. I do Restful architecture using CRUD repositories. Most of my clients don't have a lot of advanced requirements within their applications.

I'm now looking at node.js and it's performance implications (I'm addicted to speed), but I haven't delved into it all that much.

I'm wondering if

  • node.js can realistically replace my typical web development in C# and ASP.NET MVC (not rewriting existing apps, but when working on new ones)
  • node.js can complement an ASP.NET MVC app by adding some async goodness to the existing architecture.

Are there use-cases for/against C# and node.js?

Edit

I love ASP.NET MVC and am super excited with where it's going. Just trying to see if there are special use cases that would favor

Chase Florell
  • 641
  • 2
  • 5
  • 16
  • Yes, I realize this can be a bigger conversation when including Ruby, or PHP, but for this particular question, I'm not interested in either of those... that's just me. – Chase Florell Dec 08 '11 at 19:17
  • The answer is, try node. Read up about it. See whether you like it. – Raynos Dec 08 '11 at 20:00

2 Answers2

11

I'm now looking at node.js and it's performance implications (I'm addicted to speed), but I haven't delved into it all that much.

Profile, profile, profile. That's the only way to know that your speedups are having the proper affect. You can guess that it's fast enough. But most people like to prematurely optimize. That's worse than playing with yourself during a date.

I'm wondering if node.js can completely replace my typical web development in C# and ASP.NET MVC, if it's better as a complement to C# and ASP.NET MVC, or if there's some things that should just "leave well enough alone".

Are there use-cases for/against C# and node.js?

Sure, if you're in a shop that routinely writes code in C#, then you should use MVC (it's a lot better than WebForms, and is called WebPages). You're going to not lose a lot of time to tooling training, and it's something your workflows should already handle.

What you don't seem to indicate above is the reasons to choose each. You've given two current market options, one still in Alpha stages, the other on its full third year of platform release. I wouldn't want to compare the current testing model electric cars with the Honda hybrids that are already out on the market. They're in two different leagues.

Now, here's a reason for you to stay away from node.js, if you're nominally a C# shop.

You don't currently work in asynchronous evented i/o, you currently work in a procedural format.

That's the antithesis to what nodejs is going to do for you.

However, if you're frequently writing async code in C#, and you use it a lot in an evented style, then yes, node.js is for you to strongly consider.

Here's what you'll give up:

  • IIS - This is actually important to a lot of people. Things like native A/D integration are already done, and pretty bug-free. Actually node.js now integrates well with IIS.
  • Razor templating - If you've done any serious C# MVC, then you are using and loving Razor and how quickly you can churn things out. There are similar templates in node, and I'm certainly not knocking node, but the entire toolchain is already present in C#, and a lot of it is currently being built in node world. NB: a lot of this tooling is now rather mature_
  • compile-time building of dlls - node.js generally gets compiled on the fly, that is to say, not all paths are checked at startup. It's entirely possible to have really bad code in node that nobody ever touches, checks, or tests against.
  • All the tools currently built into VS that you use daily - There just isn't that much VS support for javascript. Partly because everything in javascript is so dynamic. NB: Microsoft is obviously working on tooling support for javascript_

Here's what you'll gain:

  • everything you develop will be in the same language, assuming you do client side scripting as well as serverside. (or why would you even consider javascript on the server)

So, since I seem to be bashing Node here entirely, let me point out that node is my play language at home, I love it, and I help people debug it sometimes on the stackoverflow chat servers (room 642). I see that it has great and stupendous potential in the future.

I'm just saying, don't throw out the baby and wonder why the bathwater is dirty.

You haven't given a reason why you should give up your years of experience and start on something new. Are either bad tools? Not at all. Both are great and make development a breeze.

Can node replace C#? Yes, quite certainly. So could PHP or Java or Ruby. You're not asking about those.

Here's how you know when you're ready to program node.js instead of C#:

  • You're considering writing a book to help other people "get javascript" instead of the boring old programs they've written before in C# and etc.
  • You've got problems with synchronous (blocking) I/O stopping your apps from doing actual work.
  • You aren't using ANY libraries in C# other than the default MVC and that just for routing, and you're pretty sure that you can do a better routing engine, and you're coding everything as close to the metal as you can.
  • Every data object you design you see as a hash instead of a strongly typed object.
jcolebrand
  • 1,016
  • 1
  • 10
  • 19
  • Thanks for the detailed response. I don't have a "reason" to go with one or the other. Just wondering about some of what you posted above... maturity, scalability, performance, feature set, etc. I'm not a "shop", I'm a "one man band". Also, for the synchronous goods, I've been looking at SignalR as well. – Chase Florell Dec 08 '11 at 19:16
  • `maturity` - check, they both are stable enough to deploy apps on them. `scalability` - check, because I bet you don't have 300 concurrent requests on a regular basis on ANY site you've helped develop yet. Scalability is a question that can only be asked when you have performance problems. `performance` - check, they are both rather performant, up to a point. You won't reach that point before mid 2012, even if you get really lucky. `feature set` - well, what features do you need? `one-man-band` indicates you're in college/Uni, and that you need more experience yet. – jcolebrand Dec 08 '11 at 19:21
  • 1
    My advice, go write three or four complex websites in node.js. Start small, then get larger. – jcolebrand Dec 08 '11 at 19:21
  • 1
    I'm not in college/university. I've been developing solo for around 8 years and am doing quite well for myself. I can make better $$$ on my own than under another company. – Chase Florell Dec 08 '11 at 19:23
  • Node is _not_ in it's alpha stage. It's not in beta either. It's stable live and running in production – Raynos Dec 08 '11 at 19:27
  • @Raynos why is it version 0.6 then? That's not what most people call "first release". I'm pretty sure even the core developers wouldn't call it "first release" altho they said (same as I did) that it's ready for production. – jcolebrand Dec 08 '11 at 19:29
  • I'm sorry that you don't need health insurance and the benefits of having coworkers to bounce ideas off of (the reasons I work in an office). I've considered going independent, and I don't think I would do well managing the business aspects of running my own shop. Also, I would end up hiring talented people to work for me. But, I prefer teams. I'm glad you don't. Have you written any apps in node yet? I would be glad to peer review them with my commentary and questions, if that's something you would be interested in. – jcolebrand Dec 08 '11 at 19:30
  • "Razor templating". You know razor is a third party open source module right? Just like all the other third party open source nodejs templating engines. Besides comparing ASP.NET MVC 3 to node.js on it's own is bullshit. – Raynos Dec 08 '11 at 19:35
  • not all paths are checked at startup". What? Sure not all paths are checked at startup, but neither are they in C#. You still have run-time failures. – Raynos Dec 08 '11 at 19:37
  • 2
    C# does compile time checking of all the code paths. It won't throw until bad data blows it up. Node won't stop the build just because of bad code. Or I was using an old version and that's changed. – jcolebrand Dec 08 '11 at 19:45
  • @jcolebrand re: healthcare... I'm Canadian ;-) ... re: writing node apps... no I haven't written any as of yet... just looking into it. – Chase Florell Dec 08 '11 at 19:48
  • hahaha, there's that then I suppose. I keep getting told I should consider relocating ;-) ~ Have you seen the github joyent node wiki pages? That would be a great place to start. – jcolebrand Dec 08 '11 at 20:04
  • checking them out now. – Chase Florell Dec 08 '11 at 20:18
  • 1
    @Raynos: Razor is not some third-party open source project, it is the officially endorsed developed-by-Microsoft view engine for ASP.NET MVC 3 – Carson63000 Dec 08 '11 at 20:57
  • @Carson63000 Ok, first-party open source project. Same thing – Raynos Dec 08 '11 at 21:48
  • You lot do realize that MVC3 is open source as well, right? – jcolebrand Jan 04 '12 at 18:08
  • 1
    At the time of this writing Node.js was not supported by IIS, it is now, however. – jcolebrand Dec 05 '12 at 16:59
  • 1
    I'm surprised nobody bothered to mention that Node.js isn't a web framework. – Matt Esch Dec 29 '12 at 02:11
  • To be fair, MVC is more of a methodology than anything. You _could_ do MVC with WebForms. In that regards, the real question is ASP.NET vs Node.JS. – jcolebrand Dec 29 '12 at 05:38
5

If your just doing restful architecture using CRUD repositories there is no good reason to port an existing application to node.js.

If your writing a new application that does REST and CRUD there may be good reasons to use node.js from the start.

It's really per application dependent.

For example personally I would write REST/CRUD applications fully in node.js because it's personal preference. Node is great to develop in, ASP.NET MVC was an annoying restrictive framework for me.

Verdict: Both tools get the job done. If there are no specific requirements that favor .NET or node then use whatever you want. i.e. It's personal preference.

However I can list some of the obvouis benefits of both platforms

ASP.NET

  • Windows/.NET integration. If you want your microsoft stack to be tightly coupled and highly integrated then you want .NET
  • readily available work force
  • Monolothic frameworks that hold your hand
  • Has a set of features that work out of the box. If your happy with these features it improves productivity. If you want custom features instead you end up fighting against the tool and reduce productivity.

Node.js

  • Single language for your entire web stack (if your using noSQL databases that use js for their "queries" like couch/mongo).
  • Great for soft real-time web applications using tools like socket.io
  • Great for networking glue when all your server does is talk to n remote end points of various different types.
  • Only gives you the bare minimal features out of the box. This means you can build up your application in the highly customized way you want.
  • Collection of small unix style tools that do one thing and one thing well that are easy to mix and match
  • npm : package management done right
  • rich Open source community
Raynos
  • 8,562
  • 33
  • 47
  • Yes, not looking to port existing apps. Thinking of the apps that will come in the future. – Chase Florell Dec 08 '11 at 18:59
  • 5
    @Raynos should add the disclaimer that he's a Node.js evangelist and never built a website based on MVC3/4. (I think this reflects in the answer). – Matt Esch Dec 29 '12 at 02:15