If you've been watching backend development and cloud infrastructure over the last few years, one language keeps shooting up: Go, often called Golang.
From tech giants like Google and Uber to Netflix, and on to popular DevOps tools like Docker and Kubernetes, all of them are built with this language and its cute gopher mascot.
So why did this still-young language get so popular among backend developers? Let's get into it. ๐
Key takeaways
- Go compiles straight into one fast single binary, so it needs no virtual machine or external interpreter.
- A Goroutine needs only about 2 KB of starting memory, far leaner than an OS thread at 1-2 MB.
- Channels keep communication between Goroutines safe and free of race conditions.
- Go's standard library is rich and ready to build an HTTP server without a third-party framework.
The Reasons Behind Go's Birth
Go was developed at Google around 2007 by three legendary computer scientists: Robert Griesemer, Rob Pike, and Ken Thompson. Its public version only shipped in 2009.
Back then, developers at Google faced the classic dilemma of picking a programming language.
C/C++ was fast and efficient, but its compile time was slow and memory management was fiddly. Python and Ruby had beautiful syntax and were pleasant to write, but they executed slowly at the scale of giant applications. Java was powerful, but it often felt rigid, verbose, with configuration piling up.
Go was built to take the strengths of all three worlds at once: performance on par with C/C++, ease of writing close to Python, plus a blazing compile step.
Go's Standout Features
Here are the main reasons Go is liked for backend systems:
- Statically typed & compiled: Go compiles straight into one single binary file, so it needs no virtual machine like the JVM or an interpreter.
- Blazing compilation: building Go code takes seconds.
- Simple, minimal syntax: Go was designed deliberately without unnecessary complexity. It only has 25 basic keywords!
- Garbage collection: it prevents memory leaks without manual memory management like C/C++, where one careless move leaks.
- Built-in concurrency: concurrency handled out of the box through Goroutine and Channel.
Goroutine & Channel: Light and Easy Concurrency
Go's most iconic feature is the Goroutine. A regular OS thread can eat up to 1-2 MB of memory per thread. A Goroutine? It needs about 2 KB just to start.
That means you can run tens of thousands to hundreds of thousands of Goroutines at once on one machine, without making the RAM sweat.
Think of it this way. An OS thread is like renting a whole bus to carry one passenger. A Goroutine is more like a fleet of nimble motorcycles running together, carrying thousands of passengers on far less fuel.
For communication between Goroutines, Go provides Channel. Sharing data between threads stays safe, with no clash and no race condition.
A Simple HTTP Server Example in Go
No need to install a third-party framework or library. Go ships with a standard module
(net/http) that's ready to build an HTTP server:
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Halo dari HTTP Server Go & Invasikode!")
})
fmt.Println("Server berjalan di http://localhost:8080")
http.ListenAndServe(":8080", nil)
}
Just save that code as main.go, then run:
go run main.go
In a flash, your high-performance HTTP server is up and ready to serve requests.
Want to Try Go on a New Project?
Go proves that a modern backend language doesn't have to be complicated and long-winded to run blazingly fast. With 25 basic keywords, instant compilation into a single binary, plus the memory-cheap magic of Goroutine (~2 KB), it's no wonder Go became the new favorite in the world of cloud and microservices.
If you're designing a system with high concurrency needs, or you want lean and powerful microservices, Go clearly deserves a spot on your learning list.
Happy Go-ing, and may your RAM stay roomy even when the Goroutines race together! ๐