Which one to select? ASP.NET Vs Node.js? That is the question. In the world of enterprise software development, there are many tools and frameworks that have their merits, strengths, and weaknesses. Deciding which one is best for you is crucial.
In this article, we are going to look at a comparison between ASP.NET Core and Node.js.
Both of these technologies have firmly established themselves in the world of web development over the last few years. Both pride themselves on performance and scalability, both have groups of devoted fans and highly opinionated developers behind them. In this article we’ll discuss how they are alike and how they are different, where their respective strengths lie and where they might experience shortcomings and hopefully along the way I can help you make up your mind or at least ease your decision a bit.
ASP.NET comes with a premade project/file structure, premade boilerplate and some nifty examples on how to use the MVC pattern. To a complete beginner this could be incredibly helpful as it provides an easy entry point into an architecture that is widely considered an industry standard, while to others that prefer to learn as they go it could be a hinderance or downright confusing.
Node.js with express on the other hand is as barebones as it goes. You install the express module via the NPM and then you’re on your own, what pattern your choose, how you structure your project and so on is on you. To a complete beginner or even an experienced developer this may be confusing but it’s nothing that a google search or a look at the documentation couldn’t fix.
Obligatory it depends on your pre-existing knowledge and experience.
Both languages are hugely popular and therefore provide you with an ocean of knowledge one google search away. As I’ve mentioned above ASP.NET does come with premade project templates that allow you to jump straight into developing your web app.
But hey that’s just the starting phase. How about the actual development time? I firmly believe that I can create a fully functional webapp or RESTful API faster in ASP.NET than I could in Node.js. This has a lot to do with the tooling that Microsoft has provided and the fact that most of the most important modules/plugins/nuget packages in ASP.NET were all created by the same company. Which means there’s less surprises, method names don’t suddenly switch from camelcase to snakecase and so on.
With Node.js that is not the case as often each node module is written by a different developer. These developers may have different preferences, ideas and standards. This in turn makes me consult the documentation more often than I would like, sometimes even on stuff I have done a million times. Because better safe than sorry right?
As I’ve mentioned in the point above, ASP.NET most used and important nuget packages are all developed by Microsoft, which means they will always work together and always stay concise. Where as most node modules are written and maintained by different developers with different philosophies.
This obviously has a big effect on the stability of your webapp. One day you could decide to update your project and all it’s dependencies only to discover they don’t work well together anymore or that a method you used all over your project has been deprecated or even renamed. This can ruin anyone’s day, I know I wasn’t too happy when it happened to me. Furthermore these developers can at any time stop maintaining their modules and leave you out to dry. Or at any moment the company behind a widely used node module could be bought up by another company and their direction could change.
When it comes to stability I personally like to side with Microsoft, for all their faults and I know they can have quite a few, at least you know they’ll always be around and they’ll run a tight ship when it comes to their developer tools, frameworks and libraries.
Oh boy the big one. Both the Node.js camp and the .NET camp will claim that under certain conditions their framework of choice will outperform the other. There’s articles on the web where companies boosted their performance substantially by switching from Node to .NET and vica-versa. What they don’t tell you is the gorey details. How old was their previous codebase, how experienced was the team that developed it, how many stupid mistakes and problems did the project contain and so on and so on.
Both Node.js and .NET are capable of outperforming or underperforming against each other. I know you’re sick of hearing it depends but this point really really lies on the developer or development team.
After all a good workman does not blame his tools.
BUT keep in mind that unless you are facing heavy traffic and huge request or performance intensive tasks, the difference between the two out in the real world after human error is added to the equation will be miniscule.
Only consider performance a metric if you really really have to squeeze out every last % and even then, servers cost a heck of a lot less than developers do per year.
There are only few hosting provider that support ASP.NET and Node.JS. I personally recommend ASPHostPortal and also HostForLIFE.eu. This is my choice, but there are still many hosting provider support this feature. This is only personal experience and I would recommend both providers above.
Async vs Sync
This right here is the key difference between the two. Node.js is fully asynchronous while ASP.NET is synchronous, but allows you to define asynchronous methods.
Synchronous basically means that you can only execute a single operation at any given time, meaning that all other operations are blocked until the original operation is fully executed.
Asynchronous Means that you can execute multiple operations at the same time and you do not block other operations during it.
Sounds simple enough right? In fact it even sounds like Async is always the way to go. Hold up there not so fast. Async is great and all but it can cause a ton of headaches when handled improperly. Imagine for a moment that two users submit a request at the same exact time for the same exact code block. Except user A wants to delete or update the code block and user B wishes to read the code block.
This means that user B will either get to see information that should not exist at that moment, he will see old information or will request information that does not exist anymore.
2 wrong results and 1 correct one. I don’t like the odds of that.
Furthermore more often than not I had to force synchronicity into my node.js API or webapp for one reason or another.
This is why I personally prefer the ASP.NET way of doing it. The default state of it all is Synchronous until async is required. Heck if you want you can make the entire ASP.NET webapp Async.