Introduction to Go Programming Language — Part 1

Alfian Wijayakusuma
10 min readFeb 11, 2021
https://stackify.com/learn-go-tutorials/

Update: There are some updates at Background section in this post. I also have released the 2nd part of this post at Introduction to Go Programming Language — Part 2. Check it out for more information about advantages of Go.

Hey there, welcome back to my post. At this chance I will share my basic knowledge about Go Programming Language. This post will not share technical side of Go like how to code, but it will explain Go from its surface instead to get the insight of Go.

This post is aimed for beginner who never but want to know about Go, yet for intermediate software engineer who want to widen their knowledge base.

The introduction will be divided into 4 big sections. Feel free to jump into section that you are interested in, but I suggest you to read the whole post sequentially for better insight or understanding. Those sections are :

  • Brief History
    Inform shortly about the inventors, development, and its popularity nowadays.
  • Background
    Explain deeply about reasons why a new programming language (Go) need to be invented and why Go has such characteristics.
  • Characteristics
    Explain about characteristics that Go has as a programming language.

Brief History

Robert Griesemer, Rob Pike, and Ken Thompson

Go programming language design process was started around September 21, 2007 by three inventors, they are Robert Griesemer, Rob Pike, and Ken Thompson. Go was developed internally in Google before finally it became open source in November 10, 2009. Go’s community became bigger so that in March 2012, Go released its first stable version.

Go is becoming more popular, developed by many contributors, and widely used by many tech companies and startups. Here are some data about existence of Go as programming language nowadays.

  • Stackoverflow Most Loved Programming Language 2020
Top 10 Most Loved Programming Language

Stack Overflow conducts annual Developer Survey, the largest and most comprehensive survey of people who code around the world. By nearly 65,000 developers involved in survey in 2020, Stack Overflow tries to make insight about nowadays technology popularity. ‘Most loved’ category means they who already use the language and want to continue work with it. Go has 5th place in top 10 most loved programming language. It climbed from 10th to 5th place in 2020 compared with 2019.

  • Stackoverflow Most Wanted Programming Language 2020
Top 10 Most Wanted Programming Language

‘Most wanted’ category means they who have not use it but want to learn it. Go has 3rd place in top 10 of most wanted programming language, the same place as it had in 2019.

  • Github Fastest Growing Language 2018 & 2019
Top 10 Fastest Growing Programming Language 2018
Top 10 Fastest Growing Programming Language 2019

Go has more 1,5x contributors in 2018 than 2017, while it has 147% change in contributors between 2018–2019. Unfortunately, Github did not release the research for fastest growing programming language for 2020.

Background

So we have learned about how is Go programming language popularity nowadays. But after knowing such a fact, you might think some of fundamental questions, like:

Why Go exist? Why a new programming language need to be invented? What problems that Go is trying to solve? Do existing programming languages like Java, C++, Javascript, Python and friends are not enough?

This section tries to answer those questions. Learning the background or reasons behind Go programming language invention is important to give us insight about general technology development, to understand problems Go intends to solve, and to get better understanding about Go’s advantages.

I think it is important for us to refresh or learn about concurrency and parallelism terms before we jump into the points. You can read this post for reference. You can learn it briefly by jump into the theoretical definition or also read the case study for better understanding about concurrency and parallelism.

1. Hardware Limitation

Processing power and memory capacity in computer is related with transistor. Transistor can perform calculation and data storing. More transistors means more parallelism in electronic circuit that cause more processing speed. So simply, to increase processing power/speed we can just add more transistors in Central Processing Unit (CPU). In computer, collection of transistors are making an Integrated Circuit (IC) and collection of ICs are making a processor.

A man called Gordon Moore, a Co-founder of Fairchild Semiconductor and CEO of Intel, in 1965 wrote a paper that lead technology development. The paper was named “ Cramming more components onto integrated circuits” by Moore until Caltech professor Carver Mead popularized it as term Moore’s Law.

Moore’s Law says that the amount of transistors that can be placed in an IC doubles every year. After Moore saw the development, he revised his statement in 1975 that it would doubles every 2 years. It affected tech industry to innovate and develop their product. They set it as target to be achieved.

The law is true until around 2012. Companies and researchers started to feel the slowdown of Moore’s law since of limitation like more cost to put more transistors and ‘quantum tunneling limit’ problem (check this out : https://www.quora.com/What-is-Quantum-Tunneling-Limit-How-does-it-limit-the-size-of-a-transistor). Hence, researchers and innovators searched another way to solve the problem to increase processing power.

This is the reason why multicore is exist. Manufacturers started to add more cores to processor. After multicore, hyper-threading, adding cache in processor, and even adding more processor (multiprocessor) is done as another way to increase processing power in computer system. With this scaling, it offers concurrency term to optimize the hardware capability nowadays.

After solve those problem, researchers found that there is Amdahl’s law that explain that a system latency to finish task execution can be improved with increasing of resources (execution units). But, he mentioned that maximum limit of optimization system can get is limited with portion of program that can be parallelized. It means that not all cases/problems could be solved by parallelization. No matter how much resources provided, the speed is depend on portion of parallelized tasks. Hence, researchers start to take a look at concurrency term as something important to utilize nowadays and future processors.

2. Modern Computing Environment

The technology that grow rapidly is resulting computing environment nowadays become more and more modern. Start from a single processor with single core, developed into single processor with many cores (multicore), many processors in a computer system (multiprocessor), and even cloud computing. Moreover, due to the hardware limitation that has been discussed before, it causes nowadays computing environment trend to be scaled horizontally (by increasing the amount of resources e.g 1 RAM into 2 RAMs), instead of vertically (by increasing the power of one resource e.g. RAM 256 GB is upgraded to 512 GB).

Horizontal vs Vertical scaling

All of this condition bring parallelism to utilize hardware capabilities. Moreover, with a condition that not all problems are parallelizable, it makes concurrency to take an important role to optimize execution of program in nowadays computing environment.

Concurrency concept lets us to think about how to structure our program to be executed optimally. It encourages us to break down a long process which has many times or long time of waiting state into pieces. With this approach, we can execute them concurrently to eliminate waiting time. For example, there is a process to hit 10 APIs. Let say to get response for a single API will take about 1 second. So the process will take 10 seconds in total. But if we apply concurrent design, we can break down that single process into 10 smaller processes. Each process now will hit only to a single API. With spawning new thread (or goroutine in Go) for each process, then we can get around 1–2 seconds of processing time in total.

3. Concurrency is Hard

We just learn that concurrency is important, but it is just hard to be programmed. Programming language that day was not designed with concurrency matter as foundation at first time, but their existing design is modified to fulfill technology demand. Hence, programming language like C++ which is found around 1990s and Java in 2000s do not have full support for concurrency, including easiness to program concurrent system.

4. Google Engineers Problems

Google is a big tech company. It has many and big hardwares and softwares to be handled. The scale also has changed, “today’s server programs comprise tens of millions of lines of code, are worked on by hundreds or even thousands of programmers, and are updated literally every day” a statement which I quote in Go official site. The statement implies that today’s development is getting more complex and the delivery is need to be faster.

With condition above, Google’s engineers were facing many problems for developing softwares. Some of them are :

  • Existing programming language and environments did not satisfy needs of Go’s engineer. To build large scale application, Go’s internals got frustrated with that days programming language. People need to choose between efficient compilation, execution, or ease of programming. No programming language has all of those advantages. They moved from safety into efficient programming language like Javascript and Python than C++.
  • Bigger scale of software means slower compilation/build time. That is what Google’s engineers suffer in development. This issue results a not productive environment.

We have discuss the main problems that lead the creation of Go programming language. There are maybe still many minor problems that I do not explain in this post, but hopefully explanation of those major/main problems is enough to give you view about background such as technology development, software engineer problems, and limitations that lead into creation of Go.

Characteristics

Learning characteristics a programming language has is important as reference to know whether that programming language is fit for you or your team and also fit to your business needs.

1. General Purpose

Go as a general purpose programming language is designed to solve general problems, while domain specific programming language is designed to solve specific domain needs. Go can be used to make web server, desktop, and console application. Although it has wide usage, however Go is focused to build concurrent and scalable web services.

2. Procedural Programming Language

Even though Go is procedural programming language, Go also support functional and object oriented programming. Go has types, interfaces and methods, but it has not type hierarchy as OOP language has. Moreover, the approach of interfaces in Go is different than general OOP language like Java. It is said that it has more general concept of interface. Go supports functional programming like anonymous function, closures, and first-class functions.

3. Composition Over Inheritance

Polymorphism is concept that ability of variable, function, or classes to take multiple form. It makes same operation to behave differently in different context. Polymorphism makes developer can reuse the code.

Go supports composition, a principle that classes are composed of other classes which implement desired functionality.

Go support interfaces (as in OOP) that support to compose things. With interface, we can use same interface to create methods which behave differently in different context. Interface in Go is implemented implicitly.

4. Compiled Programming Language

Compiled programming language means the source code will be translated by compiler from high level and human-readable language into low level machine language. The Go compiler will outputting single independent executable file for target operating system.

5. Platform Independent / Cross Platform

Go is said platform independent or cross platform because Go has libraries which support the compiler to compile Go source code into executable program for many platforms.

We just need to define target operating system and its arch to do cross compile. Go supports cross compile for Android, Darwin (Apple’s programming language which form core set of components in iOS, MacOS, and other Apple’s OS), DragonFly, FreeBSD, Linux, Windows, NetBSD, OpenBSD, Plan9, and Solaris.

6. Statically Typed

Go as a statically typed programming language, requires programmer to define variables type so they are known/declared at compile time. The compiler will check variables type in compile time, hence we can get earlier feedback from bugs.

7. Has Garbage Collector

Garbage Collector (GC) is a feature how our runtime system can manage our memory allocation and reclaim. GC will detect and clean our memory from unused objects which were created before so it can be reused.

8. High Concurrency Support

As mentioned before, Go has concurrency as its foundation.

We have learned briefly about the history and popularity of Go. We also have learned about how nowadays conditions demand a new programming language to be innovated. Finally, we also have learned about Go’s characteristics. Hopefully this post could give you the insight of Go programming Language. If you want to learn more about Go, you might want to check my 2nd part of this post at Introduction to Go Programming Language — Part 2.

--

--