DEV Community

Cover image for Why Golang ?
Pratik Tiwari
Pratik Tiwari

Posted on

Why Golang ?

Recently I have been exposed to golang considering the radical popularity of the language and talks about how it is very efficient in building microservices. I have been learning about microservices and wanted to experience golang as the syntax is comparatively easier and very similar to javascript.

But the question is understanding why go? This article answers the question. I have understood this question and have taken references from various sources to answer this question precisely.


Open Source and Simple

I think it is really very important for a language to be open source in order for the dev community to be indulged actively in the growth of the language and also to interact with it and contribute.

It has a clean syntax. It's a function programming-based language hence people coming from javascript have a very easy time learning it. Also as the syntax is easy it's easier for new dev and people to be onboarded on the projects and start working on them.

It is easy to learn, concise, expressive, and readable.


Fast

Go is compiled to machine code, it will naturally outperform languages that are interpreted or have virtual runtimes. Go programs also compile extremely fast, and the resulting binary is very small.

Golang can boast speeds of close to four times quicker than its interpreted and dynamic friends. That said, very little can touch C++ (and most C languages) when it comes to speed. All of the time spent coding and compiling pays off here.


Concurrency

Golang has efficient concurrency, like C, C++, Java, and at the same time concurrency in Go is done much easier thanks to goroutines, channels, and garbage collection.

What is concurrency?

Concurrency is the capability to deal with lots of things at once. It's best explained with an example.

Let's consider a person jogging. During his morning jog, let's say his shoelaces become untied. Now the person stops running, ties his shoelaces, and then starts running again. This is a classic example of concurrency. The person is capable of handling both running and tying shoelaces, that is the person is able to deal with lots of things at once :)

Concurrency is not parallelism. In case you are confused between them go through this article in the reference to understand that in deep.

Additional References:

Understanding Concurrency in Go (Golang) | golangbot.com

Goroutines - Concurrency in Golang | golangbot.com

Concurrency in Go is SO EASY! - Go / Golang Concurrency Tutorial


Garbage collector

A form of automatic memory management that has a significant influence on performance and helps to make concurrency more efficient.

want to understand garbage collection in deep?

An overview of memory management in Go


Fewer Bugs

Since it is a compiled language, with very strict typization, and it is statically typed, developers have to be more accurate and attentive, so the code is neater and safer.


Conclusion

So concluding GO is really scalable due to goroutines(concurrency).

It is performance efficient. Go developers have said that Go shows the same characteristics of C and C++ in terms of speed and performance, which is really good. Also due to its amazing memory management, this also plays an important role in performance.

And top of all these it has a simple syntax and GO community is growing exponentially.

Hence it becomes an amazing backend technology for dev and companies who are open to incorporate the new tech.

Discussion (0)