If you had enough of single threaded behaviour of Node and are ready for the next level (/s) - I strongly recommend you evaluate Go for your next project.
- Light weight
- Easy to create, deploy and maintain applications
- Many, many packages that make it easy to add new functionality (yes, I love them packages)
- Decent performance
However, there are a few concerns -
- Single threaded nature can be a cause for concern at some level. Yes, there are promises but with due respect to them - there are going to be transactions that can still make the engine “stuck”. CPU-bound, high performance tasks can be a problem in Node
- Treatment of numbers as floats are perceived to be harmful for applications that treat such transactions as sacred
- Types help in development-time and runtime validations that avoid all that additional code checks. Medium to high complexity projects can be (arguably?) easier to maintain with typed languages.
Aside: While I use Typescript in many projects, I cannot firmly switch over to that camp. I love the “type less” nature of JS and it keeps my productivity high for smaller projects. Also, I found it easier to switch all the way to C# or Go.
The alternatives I evaluated were -
- Rust: Seems to be everyone’s darling nowadays, but is hard to learn and is certainly not a “highly productive” language for something like web development
- ASP.NET and C#: I love the way C# has been developed over the past many years. I have used C# only for amateurish desktop applications, and am not afraid of extending it to web. Web assembly support and Blazor make this an exciting space
- Golang: Simple to learn, code and deploy (thanks to the highly touted “single executable” nature of Go). Really light-weight and quite exciting async programming experience
Finally what drew me to use Go was the “promise” of easy async programming using go routines and the promise of better & consistent performance. Though I doubt whether I can put either of these to active / practical use and see exponential gains for any of my applications in the near term.
Advantage Go for web applications
Here’s a quick take on why you should consider Go in your toolset for web development.
Go lang is easy to learn.
Despite the strictly typed nature of Go and more complex concepts like channels, coroutines, et. al, one can easily start identifying everything that a given program is trying to do quite easily. I found this easy to pick up nature quite invaluable when trying to evaluate the complexity of web applications which were created by others but I had to go in and make changes.
Yes, Go is as light-weight as they come despite being “decently productive”.
I can run more production applications, even more POCs and then some on a single VPS without any problems. While I did not quite have any issues per se with NodeJS based apps, I would love to imagine a not-so-distant future where I can deploy hundreds of smaller applications without spending a fortune using Go.
I am not going to lie. Despite reading up quite a bit and finding for myself on how performance of applications can be specific to a given use case, the promise of high performance in Go applications is a strong one.
After looking at Techempower benchmarks for a few years, I had resigned to the fact that my favourite frameworks are not going to be burning rubber on the road anytime soon. Go (and to a certain extent C#) is one of the ways of “future-proofing” my products and re-assure to myself that I can build “fast applications” for thousands of users.
Do note -
- often times, performance is a concept highly specific to your use case
- using a language does not ensure automatic high-performance, but the language features like async programming, “ability to make the machine work to its fullest” help. Compiled languages are often better here
- Web applications often do not have the same issues as their desktop / mobile counterparts. For e.g. Fastify + Postgres ranks higher (#148) as compared to ASP.NET + Entityframework Core + Postgres (#149!). Using an ORM in Fastify can of course throw a spanner in these results. A highly productive framework like Nest + Fastify + Mysql is not far behind (#189)
* Performance rankings are good as of 2020
Go has lower memory footprint. It also compiles to a specific platform and occupies lower space (the latter is not quite an evaluation factor in this day and age). For me low memory usage translates to better scalability.
Concurrency and the ease of using async programming also contributes to better scalability. You could potentially use Go routines to start hundreds or thousands of threads on a 1 GB VPS without issues.
Go is easy to learn, comparatively easy to develop, and easy to deploy. Go also features in-built code formatting rules, good support in code editors and a good packaging system.
The Bad of Golang
While I would love to use Go for command line applications, I am not too sure I will switch over my web apps really soon.
- There’s a lot of typing/copy-paste involved. Go’s simplicity also means fewer functions that provide good abstractions for common tasks. While I would love to use
- I don’t particularly like the error handling (
if err != nil). I grew up thinking the world of
try/catch- so this may be an “old-man problem”
- Golang was blessed on us a while back, but there are far few gigs on Go. SMBs stay away from the Go world since they don’t see enough developers available (= expensive to create and maintain). This is a problem for my “develop everything despite severely limited resource” mentality
I could not avoid a direct performance to NodeJS and the thousands of frameworks therein.
- Node frameworks offer “more”. I can completely switch to Typescript and code like Angular in NestJS, or go kaput with my own structure using Express/Fastify
- Examples, demos and learning resources are bountiful in NodeJS. For e.g. integrating your favourite payment gateway is made easier with examples and possibly a SDK for NodeJS, not so for Go (though you could use their APIs as easily)
- Learn Go
- Use Go for side projects
- Don’t completely switch over (unless of course if you are in a Go-friendly company)
Are you sold and want to try out Go?
- Start with the “tour of Go”
- Once you are ready, start with Fiber framework. While frameworks are not as important in Go as in Node, Fiber makes transition easy since it follows the same concepts as ExpressJS
Also see: start on golang with Fiber.