ASP.NET Web Api vs Node.js
Sadly I had experienced many difficulties in writing WCF services for my PHP web platform, slow development, very (very) complicated configurations in-order to respond well in JSON and to work RESTful and more.
Any thoughts or suggestions in the matter? Does anyone have experience in writing web services in Node.js and can point me in the direction of a good tutorial? or am I way off and I shouldn't be using Node.js for web services at all?
I have just recently started working on express.js. Let me tell you it's not for the fainthearted. The whole mentality of "If you are already familiar with JS then that's half the battle." really couldn't be further from the truth. I.E. if you are a hardcore devops guy like me.
I have a unified build process for all my asp.net application build, test and coverage reporting, deployment, configuration management and code quality analysis all setup and automated. It takes me literally 5 min to setup a Build process around a new project and have it tested, analysed, staged and shipped off to a production environment. (And really so should all the devs in the world. But hey, who am I kidding.) Then there's the monitoring, logging, performance analysis and profiling. Again all well unified, orchestrated and centrally managed.
I'm not saying node.js/express.js doesn't have those, but you have to develope/learn a COMPLETELY NEW set of services and platform just to run node.js.
Hammering out a bunch of code is one thing. Running a production system on a foreign technology is something else altogether.
Unless you looking for trouble ahem i mean, challenge :D, stick to WebAPI. WebDeploy is a god send.
BTW. Use BasicHttpBinding with your WCF endpoint and get PHP to generate the client class from the WSDL. Yes. Soap is your answer, not an "easier to use rest". Something like https://code.google.com/p/php-wsdl-creator/. Archiving the WSDL from the WCF endpoint also allows you to track with pin point accuracy of your service signature and format changes. It ensures type safety, and handles ser/de for you. I don't care much about how ugly the message looks if I don't have to deal with it. And yes I have done it before with PHP and python. Works flawlessly.
After 10 years of .net development, I wanted to use Nodejs for a mid sized application. I am Just sharing my experience.
Most of the new apps are deployed in cloud today. For a Asp.net we need windows, though it works on Linux using mono, I am not confident enough about performance. Windows server alone requires more than 750mb of ram, I wanted deploy my app on 1 GB memory server to reduce the cost. So I wanted tiny OS. Linux is proven for it. In this case Linux wins, hence node js. However I believe Windows Nano Server can address this in near future. Now .Net (core) runs on linux
Now .net core is the next Node JS. It has open the door for C# to run on Linux and Mac. Unity, Xmarin allows to create mobile apps and games too. We can now create .net standard library that can work on .net core, framework, xmarin and Unity.
Best time for C# developers.
Quicker to code
I can code well in C# as well as on js. So this is not a problem for me...
nodeJS is very simple, No dlls, no GAC, No classes. It is tiny, really tiny code. But "Code Clarity" is important for me than the number of lines I write. For me simplicity means easy to read, not quicker to code. I feel C# is simpler than JS when the code base grows.
This is debatable. I feel I can write good performance apps using both the technology.
Open Source libraries
Nodejs wins here. Too many packages, it is like tons of varieties in your breakfast. It was hard for me to choose what I want. I spent a week on ORM libraries for NodeJS, looked around Sequlizer, Sails, Knex, all of them is great. But there are people completely re-coded their app from one framework to other. That clearly shows that every framework is missing something. This never happened to me in .net world. I am happy with Dapper, and Service stack ORM lite.
But we have more choice in node js, so if we choose properly everything is going to be fine.
Docker is cool one. Who will say “I don’t want it”? This is the main thing I wanted for windows. I heard Microsoft already doing something. We have to wait and see…
Node js can run on almost on any OS, so what? I am going to use one type of OS. AWS provides very few variations of linux. For me it doesn’t matter what OS my app requires, my worry is how much cost it is. In this case Windows and Linux are almost same priced by cloud providers. The only reason I like linux is It has very small footprint. Windows is not. As I mentioned Windows Nano will address this. So I am Ok to run my app on windows server.
Now .Net core runs on linux so in docker.
Finally I decided to use C# and web api. The main reason is my existing experience on it. However I will look back to node js for my next app.
No more look back. Will continue with C# for server side, and react JS for client side.
Both platforms have their pros & cons and, ultimately, both will do the job.
However, having used both, for me Node.js would win hands down for simplicity, development/deployment speed and performance which you get out of the box - and if it doesn't come out of the box, most likely there's a package for it.
Node has been around for a few years now, however, it's only recently started to become more popular - so much so that Microsoft have vastly improved the tooling support in VS.
What about the need for cross-platform portability? What if the need is for having web api/REST services that can be deployed on both Windows and Linux servers?
WCF - I don't think it can go to Linux (yet) (mongo??) WebAPI - Can't go to Linux (I think??) NodeJS - Cross platform runtime available. Code once deploy anywhere. xyz - What else do we have that can provide all these?
At least because of this, I would suggest the op for NodeJS