Go vs Node.js is the web development equivalent of apples vs oranges. We are comparing two completely different things that, nonetheless, can be seen and used as alternatives to one another in certain contexts. Here we’ll look at the considerations that can inform a choice between Go and Node.js for backend development.
The two technologies might also be considered alternatives to each other in other contexts, such as machine learning and blockchain development. However, their relative strengths and weaknesses in those applications differ and are beyond the scope of this blog’s focus on backend application development.
This blog will not attempt to argue that either Go or Node.js is the superior backend technology. Rather, it will provide an overview of the main technical qualities of both that might influence a decision depending on technical context. As well as the business and strategic considerations that are often as influential as technical qualities when it comes to deciding on a technology stack.
Introducing Go and Node.js
Go is a statically typed, compiled, server-side programming language based on C. It’s best known for its allocated memory management, concurrent programming capabilities and speed and is mainly used in backend web development. The language is still, even sometimes by developers, mistakenly referred to as “Golang”. It has never been called Golang but the habit, which is proving hard to kick, came about as a result of the open-source language’s original domain name – golang.org.
Node.js, meanwhile, is not a programming language but a cross-platform runtime environment for executing JavaScript code and built on Chrome’s V8 JavaScript engine.
They are both open-source technologies, with Go initially developed at Google by Robert Griesemer, Rob Pike, and Ken Thompson. Like Go, Node.js was also first released in 2009. It was created by the American software engineer Ryan Dahl (who in 2018 also released Deno, a JavaScript/TypeScript runtime for enterprise-grade backend applications) and subsequently sponsored by the Samsung-owned U.S. software company Joyent.
Boiled down, Go is a server-side programming language and Node.js helps JavaScript function as a server-side language. As a result, the two technologies, while from distinct classes (programming language vs programming language runtime) are often considered rival alternatives within a backend web development tech stack.
This blog will not try to prove that either Go or Node.js is the superior technology. We will instead look at their respective strengths and weaknesses in the context of the backend web development contexts they can be considered alternatives to each other.
Both are great technologies that have made major contributions to the still-developing web development ecosystem. It’s not a competition. But by the end of this concise blog, you should have a clearer idea of when and where each might come into its own technologically. And some of the main business considerations that are also an important part of tech stack decisions.
What is Go used for? Popular applications of the programming language
Google commissioned the creation of Go in around 2007 in an attempt to find a solution to pressing challenges they were experiencing at the time, such as multi-core machines, networking and web development. The languages being used by Google at the time, like C, Java and Python, approached these challenges with workarounds rather than taking them on directly. Griesemer, Pike, and Thompson designed Go to do just that.
Tools built with Go
One of Go’s strengths as a language that compiles native machine code is that it is ideal for building software development tools. Some of the best-known tools built from Go include:
- Kubernetes
- Docker
- Terraform
- Hoverfly
Well-known applications built with Go
Just some of the well-known applications and big IT brands that use Go extensively are:
YouTube – given that Google commissioned the creation of Go to solve its own challenges it is no surprise it extensively uses the language. It keeps the exact application of Go in its products confidential but has said it is used in YouTube and Chrome.
Dropbox – the consumer-facing cloud storage giant has built most of its infrastructure in Go
A cloud computing giant tackles scalability issues with Golang. Most of its infrastructure is written in Go.
Netflix – the TV and film streaming platform’s Rend proxy, critical to its data scalability needs, relies heavily on Go, as detailed on the official NetflixTechBlog.
IBM – IBM is a major corporate advocate of Go and has created numerous products to support its Go clients.
Go strengths
Some of Go’s most noted advantages as a programming language are:
Fast
Go’s ability to compile to native machine code, thanks to its basis on C, makes it an extremely fast and efficient language.
Simple syntax
Go has an extremely simply syntax comprised of just 25 keywords, which aids readability and code clarity. A simpler syntax means fewer variables in how things can be written, in turn making it easier for the thousands of developers working on Google’s products to efficiently understand each other’s code.
And, of course, even much smaller projects than Google software products benefit from the members of a development team, past and present, being able to quickly read all the code an application is made up of.
Scalability
Go’s relative simplicity is also in favour of its scalability – another of Google’s key requirements of the language. It is designed to solve big challenges and its concurrency model (goroutines), which not only supports but improves concurrency, has been described as “to concurrency is what Docker is to virtualization”.
Go’s ability to manage up to 1000 concurrent requests per second gives it a major edge when it comes to building software for which strong scalability is a priority.
Tooling
Go’s optimised syntax, or grammar, has the benefit of equating to easy-to-write tooling. That, in turn, has led to a great array of tools being available through the go command that make it easier to manage and maintain Go software.
For a deeper dive into Go’s tooling, check out this blog article by Go expert Alex Edwards.
Maturity
Despite, like Node.js, only being launched in 2009, Go is regarded as already quite mature and robust. Probably more so than Node.js, which suffers from regular changes to its APIs that are not backwards compatible and require codebase revision.
Go weaknesses
And some drawbacks of Go as a programming language are seen as:
The need to ‘tune’ Go’s built-in garbage collection can confuse developers
While built-in garbage collection (GC) is generally in Go’s favour when it comes to scalability, it can also create issues in certain scenarios. That means GC may need to be tuned to suit the needs of a particular software application. That can be a confusing, not always appreciated, variable for less experienced Go developers.
Error handling
In Go, all errors are values. Because of this, a fair amount of functions end up returning an error. Some criticisms of Go’s approach to error handling include that it is difficult to force good error handling practice, that errors don’t have stack traces, and that error handling itself is too verbose.
Good Go developers are expensive and can be hard to recruit
Hiring competent, especially senior, Go developers is relatively expensive and there are fewer available on the market compared to JavaScript-based Node.js, which can also extend recruitment cycles. The Stack Overflow 2021 developer survey puts the average international salary for Go developers at around $75k, compared to around $55k for Node.js developers.
What is Node.js used for? Popular applications of the programming language
In the backend of a web, mobile or desktop application, Node.js is most commonly used to develop APIs or services. The runtime environment was developed by Ryan Dahl as a solution to the problem of being able to make JS run outside the browser. To do so, he took Chrome’s V8 engine, the best at converting JS into machine code, and embedded it inside a C++ program.
The combination resulted in Node.js, which shares the Chrome engine but a runtime environment for compiling and executing JS on the machine side, rather than the browser side, as Chrome does.
Node.js’s non-blocking asynchronous nature, which sees a single thread servicing multiple requests, makes it an ideal fit for real-time and other data-intensive applications that need to scale.
Categories of apps that often use Node.js include:
- Real-time web applications
- Streaming applications
- Messaging apps
- Chat programs
- Social media apps
- Virtual emulators
- Multiplayer games
- Collaboration tools
- APIs
Well known applications built with Node.js
Netflix – the user interface and data access layer are built with Node.js.
Paypal – the payment platform’s web application NodeJS for their user-facing side of its web application. Jeff Harrel, Senior Director of Payments Products and Engineering at PayPal explains Node.js’s role in the app:
“NodeJS helps us solve this (boundary between the browser and server) by enabling both the browser and server applications to be written in JavaScript. It unifies our engineering specialties into one team which allows us to understand and react to our users’ needs at any level in the technology stack”.
LinkedIn – the server-side of LinkedIn’s mobile app is built onNode.js.
Mozilla – the Mozilla Firefox web browser is a Node.js app. Mark Mayo’s Firefox’s Principal Engineer explains why with:
“We concretely decided to do Node for two reasons: One was the memory footprint” and “it was advantageous to be able to use the same language on the server side as well as the client side.”
Uber – Uber’s customer to driver matching system was one of the first applications of Node.js in a major app. The runtime was chosen for its information processing speed and ability to correct errors without requiring a restart of the app.
Node.js strengths
Some of Node.js’s most recognised strengths as a software development technology are:
Simplicity
Node.js allows for an app to share a single language, JavaScript, on both client and server sides. This brings advantages including fewer files and less code needed than would be the case if the front and backends used different languages. It also means code can be reused on the client and server sides, speeding up development.
Fullstack JavaScript developers being able to work on both the front and back ends of an app could also potentially optimise billable development hours.
Time-to-market
Node.js’s lightweight nature and allowing client and server sides to use the same language can significantly reduce development time. Deployment is also simple. Both qualities can reduce the time-to-market for apps built with Node.js.
Scalability
Node.js systems are inherently scalable thanks to inbuilt load balancing and its ability to handle large volumes of concurrent connections. It is also easy to add new modules to existing ones as an application is scaled either vertically or horizontally.
As an increasing number of apps are built as cloud-native software, Node.js’s suitability within microservices architectures designed for scalability is a strength.
Future-proofed
As one of the most known and used non-language software development technologies, Node.js will be highly relevant for a long time to come. It has an active open source community and there is a healthy supply of developers who know and have experience working with Node.js on the market. This is at least partly thanks to its basis on JavaScript, which makes it easier for frontend JS developers to develop into full-stack developers as they don’t need to learn a whole new language.
Node.js weaknesses
Some of Node.js’s drawbacks are seen as:
API instability
Perhaps the most frequently voiced complaint of developers that work in Node.js is the instability of its API, which is regularly updated with updates lacking backwards compatibility. That can lead to ongoing and often unexpected maintenance work to keep an application’s codebase compatible with API changes.
Library support gaps
Node.js’s basis on JavaScript means it suffers from the same library system deficiencies as the programming language. Several of the major NPM registries and libraries Node.js relies on are either incomplete or lack proper documentation. The incomplete library support is mainly an issue for less experienced developers who rely more on support.
Not ideal for heavy CPU-based computing
While its qualities as single-thread and event-driven are behind many of its strengths, they also mean Node.js can perform suboptimally for heavy CPU-based computing tasks. The event loop can decelerate when large CPU-driven tasks are introduced because Node.js has to utilise all its available CPU power to deal with them.
The 2018 introduction of Node.js’s worker threads module means multiple threads can now be executed simultaneously. However, while this improves the situation it does not entirely resolve the issue of CPU-bound computational challenges slowing down the event loop.
Asynchronous model
Node.js’s asynchronous model is a quality that is a major advantage in its scalability. However, it is also trickier to set up and maintain smoothly than linear blocking I/O coding and often involves nested calls. The increased difficulty can increase development time and impact the smoothness of an app’s performance.
Error handling
Node.js being dynamically typed leads to poor error handling.
If you want more technical details on the differences between how Go and Node.js handle:
- Data Types, Variables, and Constants
- Conditional Statements
- Loops
- Objects
- HTTP Server
- Middleware
- Consuming APIs
- Database Connections
This article, which includes tutorials, is a great resource for a deeper dive.
Choosing between Go and Node.js for backend development – balancing technical and strategic considerations
Direct comparisons between two technologies are always tricky, and of questionable value, without full context. Because they are so different in character (programming language vs runtime environment), that’s especially the case when discussing Go vs Node.js as alternatives for backend development.
A decision on which to opt for will depend heavily on both the specific technical requirements of a software development project and strategic considerations. The latter can be as, if not more, influential than the former.
For example, using Go rather than Node.js might, for a particular app, slightly improve performance. But if the project sponsor already has a team of JavaScript developers available, and other software products it develops and maintains use Node.js rather than Go in their backends, Go will probably only be chosen if its use will make a significant difference to app quality. And in a way expected to influence the app’s overall success.
The same might just as easily be said of the inverse scenario. Ultimately, a software architect must conclude which backend technology choices will result in an app that answers to technical specifications and priorities. Viable tech stack alternatives will then usually be decided between by considering business strategy.
Go vs Node.js strategic considerations
It’s already been mentioned but one of Node.js’s strengths compared to Go is the relative availability of developers. The most recent (2021) Stack Overflow developers survey shows over 36% of respondents had worked with Node.js in the past year compared to 10.5% with Go. And almost 70% of developers had worked with JavaScript, making learning Node.js a potentially easier step.
However, Go was one of the languages most developers who hadn’t yet worked with it wanted to learn. 14.5% wanted to learn Go, almost as much as wanted to learn JS and more than the 12% who were keen to learn Node.js. That suggests a potential increase in the number of Go developers on the market in future years. But with demand also rising it may well remain harder to hire Go than Node.js developers for the foreseeable future.
Go vs Node.js developer salaries
Go developers typically command higher salaries than Node.js developers because there are fewer available on the market and learning it requires becoming fluent in a whole language. It’s usually a greater professional investment for a developer to learn Go compared to Node.js, especially if JavaScript is already known. Internationally, the Stack Overflow developer survey puts the average salary of a Go developer at $75,599. For Node.js developers, the average international salary is significantly lower at a little under $55,000.
These are, of course, very general figures and the salary a developer can command is influenced by a combination of factors – level of expertise in a technology, experience and expertise in its application in specific scenarios and contexts, and broader tech stack.
But as a general rule, Go developers are more difficult and more expensive to recruit than Node.js developers. That reality can swing the balance of favour towards Node.js unless there is a strong technical argument why Go should be preferred.
In conclusion – choosing between Node.js and Go for backend development is horses for courses
The choice between Go and Node.js, or other options including Java and Python, for an application’s backend, boils down to balancing technical and business
The argument for Go is generally strongest in the context of applications that are processor-hungry or require multi-threaded tasks. However, organisations who opt for a backend tech stack built around Go should make sure they decide with open eyes and an understanding good Go developers are harder to recruit and often significantly more expensive than Node.js developers.
This is an interesting case study from a start-up that started building its MVP with Go as its backend choice before migrating to Node.js for strategic reasons.
In conclusion, tech stack choices should be made in the context of both technical and business considerations. One of the biggest, and most common, mistakes made in software development is the pursuit of technical optimisation without giving enough thought to the business and strategic implications of achieving that optimisation.
Will, sometimes marginal, performance benefits outweigh factors like slower time-to-market, higher development costs, potential recruitment difficulties etc.? The answer can be ‘yes’. Sometimes the technical edge a tech stack choice brings justifies other drawbacks. But it is at least as frequently the case that it doesn’t.
Regardless of whether you face a backend choice of Node.js vs Go, or any other tech stack dilemma, make sure the decision is taken with full consideration of both technical and strategic strengths and weaknesses.