Node.js vs Go for Web Development

Recently I’ve switched from using Node.js to Go for the backend and I’m never going back. Every project I worked on in node required scavenging google for a tutorial on how to use a different NPM package’s API. Perhaps there’s a method to this madness, but shouldn’t the programming language come baked in with these helpful packages?

Go actually discourages using other people’s libraries in your own code. Web frameworks exists, but most users prefer using just net/http. The reason is mainly because every library that Go comes with is well documented. No more scavenging Google for a simple tutorial on the library you’re using (node has hundreds for each and who knows who wrote it).

The languages

JavaScript has a huge flaw in that the language was built in ~one week and it’s constantly being updated because of this. Go on the other hand was built by Google and the language just makes sense. NPM is currently a mess with libraries using Javascript es5, es6, es7, or is it ES2015, ES2016? The point is that these libraries will be outdated in the next few years with Node.

With Go your code will remain intact in the foreseeable future and every library you use will also because you’re not relying on a third party. A lot of people complain about Go’s syntax, but if that’s the only thing they complain about then I’d say it’s a pretty good language. Spend one hour reading a Go tutorial and your set, but Javascript requires months to get the basics down and even then the language will change in the future.

The difficulty

Ok Node.js get’s this one hands down by far because coding in node is equivalent to a monkey on a typewriter because most of the time you’ll produce stuff that kind of works. The libraries will abstract everything and make it extremely simple to get things done.

Go on the other hand will require you to sit down and read the docs and if you don’t understand stuff then good luck because no one produces tutorials. Again, this is because the docs are already pretty good at explaining. To this day I still haven’t figured out how to broadcast a message to all users connected via websockets. In node this is a piece of cake.

Production

For node apps I usually npm install pm2 and never worry about the app crashing because it handles everything for you.

For Go you’d use supervisord to keep it alive. Requires a little steeper learning curve and more hands on.

Conclusion

If you require a more robust language go with Go and if you just want to just get sh*t done fast use Node.