Reasons Why I Chose Go over NodeJS as my Primary Programming Language

Junerey Casuga
4 min readMay 24, 2022

--

Photo by Chinmay Bhattar on Unsplash

There are already a lot of articles out on the internet that talks about why they chose Go over other programming languages. And most of them would talk about how much faster Go is compared to others.

While it’s true that Go is known for its performance, it is more often that I’m attracted to the developer experience a language offers.

In this article, I will be talking why I use Go more than NodeJS as my primary programming language.

To bring more context to this article, I have been in the web development space for a decade now. I started my professional career with PHP, which was probably more or less the norm back then. About 5 years ago, I have mainly focused on backend development by writing internal tools and developing APIs for mobile apps. And at the same time made a switch to NodeJS. And for the past couple of years, I have been working more and more with Go, both privately and professionally at Appsynth.

What is Go?

I didn’t really want to touch on what Go is in terms of who and when it was developed as you may already find a lot of these online. Instead, I just want to focus on what I liked about the language itself compared to my previous primary language, NodeJS.

If you’d like to learn what Go is, it’s best and would highly suggest to visit their website as they already provide a very nice documentation about the language.

Simplicity

Most people would describe Go as a simple language. And I wouldn’t argue on that as it is indeed a very simple language. With Go, it is more likely that you’re doing things in just a single way as opposed to other languages that you may perform the same task in various approach.

Let’s take looping as an example. In JavaScript, there are several ways of performing loops/iteration depending on what what you’re trying to do. While in Go, there is only one way of looping, just in different patterns.

For loop comparison
While loop comparison
Array/Slice iteration comparison. Take note, I haven’t even included JavaScript’s Array.forEach

If you haven’t already noticed, looping in Go is using only one way of looping, i.e. for loop, just in different patterns for different purposes.

While JavaScript’s way of expressing things in multiple way promotes flexibility, it also leads to inconsistency among developers and projects.

Standard Libraries

Go comes with a robust list of standard libraries including some features that would sometimes make you want to install 3rd party NPM modules when using NodeJS.

Yes, I said “standard” libraries. Which means Go developers don’t need to spend time searching and choosing between different libraries from 3rd party providers.

An example of that is when working with dates. While JavaScript allows you to work with dates without installing 3rd party libraries, it’s more often that JavaScript developers tend to reach for 3rd party modules. And it’s also more often that JavaScript developers need to pick and choose which module to use amongst many such as date-fns, luxon, dayjs, and many more.

With Go, the time package already comes out-of-the-box and in my opinion is way more easier to use compared to JavaScript’s default Date functions.

Using Go’s standard libraries mean these out-of-the-box features guarantees high reliability.

If you’re working on JavaScript projects for a while now, you probably also already know that reliability has been a problem in the community several times. Worst, it has broken the internet and may occur again in the future.

Concurrency

While JavaScript has already concurrency implemented, Go was designed with a very high focus on concurrency since the beginning.

Go relies very much on simplicity when it comes to concurrency. Talking about simplicity once again, there is only one language construct for asynchronous programming in Go, while there are many different ways in JavaScript.

Tools and CLI

Go comes with a range of tools bundled in a single CLI.

It comes with a compiler that can turn your code into an executable binary, even for specific CPU architectures and operating systems, which allows you to make deployments more simple as you only have to take care of a single file.

Code formatting and linting also comes with the language out-of-the-box, and works seamlessly with your code editors. All you have to do is to install Go and you are good to go 😉

With JavaScript, you would often need to install a 3rd party library yet again to have these features.

Conclusion

Should you choose Go over NodeJS? I think this decision is subjective. If you are a developer and looking for a better developer experience and performance gains on your applications, then I would highly suggest looking into Go.

I may have already chosen what language I would like to use for most part, that didn’t mean that I will stop writing in JavaScript/TypeScript.

--

--