Written by Nikola BOŽIĆ - TheExpert SQUAD / Lip6, Sorbonne Université
During our research on blockchain we have examined several platforms to test our solutions and evaluate the system performances. Hyperledger Fabric, the blockchain platform, offers several options when it comes to the programing languages. Mutli host setup, used for setting up Fabric infrastructure in production, allows developers to develop a transaction logic in GO language (GoLang). For the first time, GO was announced in a 2009, with its first version finished on 2012. In August 2015, the version 1.5 was realized with the standard library finished, hence GO have been seen as a really new paradigm in a computer science's world. But ‘Why GO?’
Why new language?
Arguing that other languages do not meet current needs, some of the most prominent people in computer science at one of the strongest software engineering firm, Google, created GoLang. In fact, language was created by one of the most influential contributors to computer science: Ken Thompson, who contributed also to the creation of C, Unix and UTF-8 which are fundamentals in computer science, Robert Griesemer (Hotspot, JVM), Rob Pike (Unix, UTF-8), and more engineers at Google. After those achievements, it was really astonishing to invent something new, and yet GO was created!
In Google's words, “Go was born out of frustration with existing languages and environments for systems programming”. Programming had become too difficult and the choice of languages was partly to blame.
Over the past decade, raw processing power did not change too much. Clock speed of 3.0 GHz used still today was introduces back in 2004 within Pentium 4 processors. Furthermore, in order to improve performances, manufactures started adding multiple cores to the processors, introducing hyper-threading and increasing cash memory. Reaching hardware limitation, logical path aiming to improve the performance is more efficient software! Nevertheless, most of the previous system level languages were designed for single threaded environment from the ‘90s, written to run on a single core, without scaling with respect to increased number of cores. Hence the GO is designed accordingly. It is a compile language, that is to say, there is no VM running on top of underlying OS. Compared to Java, no interpreters, it directly compiles the human readable code to binaries, understandable to processors, thus quite fast! GO bring the best from both, written as a system-lower level language with some powerful standard libraries that allows a high-level programming. It also uses garbage collection to allocation and removal of the object.
Before GO, developers had to choose between efficient compilation, efficient execution, or ease of programming. All three in one was impossible. The objective was to finally make it possible. A motivation was to create a modern language that easily uses multiple cores, easily implements concurrency, easily works in distributed environments, and easily allows the programmer to write programs via user-friendly and neat syntax.
It also aims to be modern, with support for networks and multicore computing. Google designed it according to their needs. As they have thousands of contributors to the same code base, they had in mind to enable that one segment of the code has minimum side effect on another segment. Thus, many features of modern OOP languages have been left out like inheritance, classes, constructors, annotations. This makes code easily maintainable and easy to modify, preventing side effect. Nevertheless, some may not appreciate this changes which make GO quite different from classical OOP languages. The bright side is that syntax of GO remained the same since its release 1.0 in 2012, making the syntax stable and backward compatible.
Why using languages if nobody is using them, right?
Aside above mentioned improvements, GO is today used by many companies. Just some of them are listed here, but the whole list is very long!
One more thing! Following the motto 'do less, enable more', GO is used for web apps, scripts, system administration, image processing, load balancers, servers, crypto, hardware and even Android and IOS apps. All that with just one language! It seems that GO gives a big spectrum of possibilities.
To point out, even though GO is quite different from other object-oriented languages, it still provides high performance like C/C++, super-efficient concurrency handling like Java. Hardware limit puts pressure to software developers to write super-efficient code, making developer oblige to understand the hardware to make their programs optimized accordingly. Nevertheless, the optimized software can run on cheaper and slower hardware, (like IOT devices, sensors) with an overall better impact on end user experience.
How to start with GO lang?
To start with GO, first, go to play.golang.org to open a Golang playground. The playground is a place where you can run your GO code within the basic GO structure. You can even share the code just by providing the link. One more great thing, GO does not use semi, they are added automatically by a compiler. Personally, we found this quite useful.
Furthermore, downloading and installing GO is fast and easy following well documented instruction.
To get more familiar with GO, visit godoc.org where you have access to all libraries.
References to useful materials can been found hereafter. Have fun!
- golang.org – wery deatiled documentation with tutorials.
- Go Books:
Some free trainings :
- YouTube playlist – Golang Web programming https://www.youtube.com/playlist?list=PLSak_q1UXfPpXj-q1BeucvBAlNdotQWVD
- Followed by the code base in GitHub https://github.com/GoesToEleven/golang-web-dev
- Another YouTube playlist https://goo.gl/BjXZol
- Code base https://github.com/golang-book/bootcamp-examples
And many other tutorials available online! Enjoy!