What do you do for your own self-development?
The author of this publication is Krzysztof Kura, Full Stack Web Developer. Make sure to check what our specialist wants to share with you.
Following this motto, together with a group of friendly programmers we decided to write a small project, which will allow us to familiarize ourselves with the programming language Go, the queries language GraphQL and the platform for creating blockchain platforms for business solutions called Hyperledger Fabric. Certainly you want to ask why these languages and technologies? I will try to answer this question.
What is typical for the Go language?
Go, called Golang to distinguish it from “go”, is a programming language developed by Google programmers. The people responsible for the main assumptions of this programming language are, among others, the designer and creator of UNIX and C – Ken Thompson, and the co-creator of UTF-8 and UNIX formats – Rob Pike. The version 1.0 was released in March 2012 (from September 2019 the version 1.13 is available) and is gaining more and more popularity among programmers all over the world. In 2016, it was recognized as the language of the year according to the Tiobe ranking.
Many large companies adapt Go to their projects, including Apple, Mozilla Firefox, Github, Uber, Dropbox, Digitalocean, Docker, Facebook, Twitter and YouTube. Go was supposed to combine the best elements of the programming world and make it all simple. Based on the opinions of users, it can be assumed that the goal has been achieved. Let’s focus on the widely described advantages.
Go is a compiled language, which allows to detect syntax errors in the compilation process and to increase the speed of action in comparison to interpreted languages. It is worth noting that it compiles very quickly if compared with other compiled languages. An important feature of this programming language is multithreading, which allows you to use additional computing power to speed up the implementation of the task that was set for the program.
Paralleled triggering is simplified for the convenience of programmers. Golang provides the so-called “goroutines”, which allow asynchronous immobilization of a selected function by adding a “go” instruction before triggering it. Shared channels, which in a very simple way work as indicators allow you to insert data into one process and read it in another. In terms of difficulty, Go is praised as quite easy to learn, but attention is drawn to the possible difficulties with understanding the workspace in which the application files are located.
I have heard opinions that there is no need to use frameworks in Go, because all the most needed functions are built into the language. In addition to that, my attention was drawn to the well-prepared documentation, which contains detailed information on how the embedded packages work. Golang has built-in methods of automatic management of dynamically assigned memory, which facilitate resource management. Thanks to this, the memory release process is not the responsibility of the programmer, responsible for this is the program manager called “garbage collector”.
Why is it worth using GraphQL?
GraphQL is a query language that gives the ability to retrieve and modify structured data in a graph. The source code of this solution, which is an alternative to the REST standard, was made available in 2015 by Facebook. The presented solution has been used in Facebook mobile applications since 2012, so we cannot say that it was an experimental solution. GraphQL quickly gained great popularity. There is a case of a company that abandoned plans to develop its ideas and implemented GraphQL. This company was Coursera. Another example of usage is GitHub, where the latest version of the public API is based entirely on GraphQL. GraphQL is often described as a good alternative to the traditional REST. How is it justified?
In order to answer this question it is necessary to remember what is the basis for the frequently used REST, which is kind of a style in API design. Generally speaking, each data model is available at a separate address. The number of addresses will grow together with the application. We deal with a completely different situation in the case of GraphQL. Only one address is issued, to which a properly formulated query is sent. In contrast to REST, the client decides what data he wants to get in the response that the server sends. With one query, the client can retrieve all data of interest to him without redundant information. This flexibility is the main assumption of GraphQL. The expected consequence of this solution is a decrease in the number of queries, which will enable optimization of the communication between the client and the server. This is very important e.g. in the case of mobile applications, where a large number of queries increases the transfer of data sent over the Internet.
It seems important to choose a defined API. In the case of REST, it is not clear what can be expected in the response. We know that maintaining good and up-to-date API documentation requires a lot of discipline. Based on the information found, strong typing in GraphQL facilitates the process of preparing documentation. For this purpose was the GraphiQL tool developed, which is also available in the form of a plugin for Chrome browser. GraphQL’s success is also due to the fact that it is technology independent. Ready-made libraries are available to implement this standard in the most popular programming languages.
A few words about Hyperledger
Hyperledger is the name of an organization founded by IBM, which brings together many projects run by the Linux Foundation. The foundation is known for supervising open-source projects. Among them there are many remarkable projects, such as the famous Linux or Node.js. The projects Hyperledger focuses on are related to blockchain networks in business applications. In 2015 IBM passed the source code of its solution under the name Open Blockchain to the open source community, which became the basis of the Hyperledger Fabric platform. An example of using Hyperledger Fabric on the Polish market is the publication and electronic access to public documents by PKO Bank Polski. The conditions for a durable medium were met thanks to the blockchain technology that was based on Hyperledger Fabric. The developed tool enabled the first blockchain production implementation in the banking sector in Poland. For what is the aforementioned Hyperledger Fabric recognized?
Hyperledger Fabric is a blockchain-based solution for business. Attention was drawn to the need for network surveillance and maintaining privacy through verification of its users. This solution allows you to define permissions for each node separately. It is possible to create channels to which only selected members of the network have access, which is not possible in public networks such as Ethereum.
Read also: How to get into Project Management
Transactions are added to the blockchain network to which the participants of the selected channel have access. An additional reason for using Hyperledger Fabric is the issue of scalability. In the case of the Ethereum network, we are able to record 15 transactions per second. In the case of Hyperledger Fabric, it is a number of thousands of transactions per second, which is significantly higher. In addition to this, users are not looking for incentives to confirm transactions, such as the PoW tokens.
I hope that I have been able to justify sufficiently the choice of languages and technologies that will be used in the project mentioned in the introduction. Once the project is completed, I will present conclusions on the languages and technologies used. I hope that I have drawn your attention to the languages and technologies that I believe require it.