Why I preferred Go over Node.js for simple Web Application
We all know that for REST API backends Node.js is fantastic choice specially with MongoDB combination. But when I’ve tried simple service using Go, I’ve been surprised how easy it is to write Web API using Go and deploy it to server.
Main Differences For Me
For example to run function concurrently you need only to write
And we all know that with concurrent programming you are writing less code than with async style, because of the callback hell like this one, which is the same as the top Go code.
So actually JS is very fun language and it have tons of information and huge community behind it, and Go would never replace Node.js in server side web application programming, but it turns out that if you are trying to write Web API with minimal functionality but with critical speed and scalability we probably need to choose Go, because it
- scales to multiple CPU cores automatically
- compiles to single binary file which is super easy to deploy and run
- have built in logging tools for monitoring
- performs better in backend tasks like file I/O or CPU based operations
I would say that in large web applications/API’s you definitely would use both of the languages because they are completely for different use cases, but for building basic file sharing application like Flaxton.io I preferred Go because
- Less code is always better :)
- I don’t need to install Node.js and NPM on server during deployment I need only binary of
- It is core File I/O based operations so Go is better for that.
I think you need to take a way from this is that
Less Code is Always Better!!