Why GoLang for Blockchain?

Prakash
3 min readFeb 12, 2020

--

Before why, what is blockchain?

A blockchain is an immutable transaction ledger, maintained within a distributed network of peer nodes. These nodes each maintain a copy of the ledger by applying transactions that have been validated by a consensus protocol, grouped into blocks that include a hash that binds each block to the preceding block.

Let’s call it a problem-solving technique that is getting popularity these days. Now, this technique can be implemented in any language which supports basic principles of OOPs, Data Structure, etc. From the developers' point language should be easy to understand and efficient.

One can implement Blockchain with a good knowledge of OOPs, Data Structures and JavaScript with any language like Java, NodeJS, Python, Ruby or even with C++.

If these many options are there then, Why Go (GoLang)?

First, Go is an open-source programming language from the house of Google. According to ‘Rob Pike Co-designer of Go’, the language was developed as an answer to some of the problems they faced internally in developing software infrastructure at Google. It is dynamic like Python and simple like C.

Easy to Maintain in long run

A blockchain can require thousands of lines of code, we want a language that could make the maintenance of such a huge project very easy. Go is simple and it has a very less number of quirks that save time. Also, there are very few things to learn and a few ways of doing the typical.

Speed and Efficiency

Go is a compiled language, so it reduces the overhead of ‘on-the-fly’ error that happens in an interpreted language like Python. This is like C where code compiled first, the error displayed and asking to resolve then only code runs.

A blockchain needs to be very efficient mainly due to cryptographic calculations and huge amounts of data it has to propagate as well as store in the network.

Made for distributed systems

There are many tools and software which have been built using Go. Docker, the container used for microservices is built using Golang.

Microservices built using Go easily scale to millions of requests as compared to PHP.

Goroutines

Go has the ability to run several programs or several programs asynchronously or in parallel, which improves the throughput. In java, threads are used to achieve concurrency while in Go goroutines are used.

Blockchain has wide importance of parallel actions, where this feature comes very handy. Also, the ability to run a lot of functions in parallel allows Go to be run on distributed systems — which is a primary need for Blockchain Technology.

--

--