Why I preferred Go over Node.js for simple Web Application

I’m developing Node.js applications and server side scripts more than 4 years and know very well how fun could be writing backend code with JavaScript. But in most of the cases with JavaScript you are actually writing more code than with other non async languages like Python, PHP or GO.

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

Go is a statically typed language which is compiling to full binary and quite fast compared to Python, PHP or JavaScript. And main thing that makes Go great language is his concurrency model and super simple syntax without OPP. 
For example to run function concurrently you need only to write

go someConcurrentFunction()

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.

}, 0);

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

  1. scales to multiple CPU cores automatically
  2. compiles to single binary file which is super easy to deploy and run
  3. have built in logging tools for monitoring
  4. 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

  1. Less code is always better :)
  2. I don’t need to install Node.js and NPM on server during deployment I need only binary of go build
  3. 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!!