Introduction to Google Go - Beginner Guide.

Introduction to Google Go - Beginner Guide.

This article is a beginner guide introduction to Golang and also for those with experience with other languages but wish to learn the Go programming language.

In this article we shall cover some basic introduction to the Google Go , by the end of this article you should know:

  • What is Go?
  • Who are creators of Go?
  • Why Go?
  • Purpose of Go.
  • What is Go used for?
  • Companies using Go.
  • Writing your first 'Hello World' in Go (This Would be fun).
  • Resources to learn Go.

What is Go?

Go is a procedural language. It was developed in 2007 by Rob Pike, Robert Griesemer, Ken Thomspon at Google but launched in 2009 as an open-source programming language. Programs are assembled by using packages, for efficient management of dependencies. This language also supports environment adopting patterns alike to dynamic languages.

Go is a statically typed language. A statically typed language is a language that perform type checking at compile time. This means that scripts written in dynamically-typed languages (like JavaScript) can compile even if they contain errors that will prevent the script from running properly (if at all). If a script written in a statically-typed language (such as Golang) contains errors, it will fail to compile until the errors have been fixed. Second, statically-typed languages require you to declare the data types of your variables before you use them, while dynamically-typed languages do not. See the examples below

// JavaScript
let name = 'Franklin' ;

//Go
var name string = 'Franklin'

Go is also called Golang due to it website (golang.org) and not go.org which was not avaliable to Google.

Who are the Creators of Go.

I would really love us to look at the genius behind this amazing language. These are the people who made the Go langauge, ideally I love to call them the 'Pioneers of Go'. They include :

  • Rob Pike - He is also responsible for making the Unix used by Apple for their operating system and also the UTF-8 engine used by all browsers today
  • Robert Griesemer - Studied under the creator of Pascal , Maybe this is where he got his amazing skills of creating amazing stuffs.
  • Ken Thompson - solely responsible for designing and implementing the original Unix operating system
    • invented the B programming language, the direct predecessor to the C programming language.
    • helped invent the C programming language

Wow!!! Great people indeed , from the above analogy of these people who came together to make this amazing language in Google Labs, it is expected to be one Hell of a language and very efficient for anyone to use and seeing it is being backed by Google is a great encouragement for anyone looking forward to learn this language.

Why Go?

You might ask 'Ok, why do i learn Go?, there are bunch of other languages outhere?'. Yes , you are right. But hang on.

Go was created in 2007 at Google by Rob Pike, Robert Griesemer, and Ken Thompson when Google hit a problem in it internal systems. YouTube serves more than 4 billion hours of video each month. About 72 hours of video are uploaded to the service every minute. While YouTube stores all its videos directly on a file system, it uses MySQL to store all the metadata needed to serve each video, such as user preferences, advertising information, country customizations and other needed bits of information.

YouTube likes using MySQL for its reliability, said Solomon, one of the engineers who originally built the service. It has quirks, but those quirks are well-known and can be mitigated fairly easily, he said. However, MySQL also has issues with scaling -- at least scaling to accommodate a service as large as YouTube's.

"The major problem with MySQL is that once you get to a certain point [of usage], you spend a lot of time managing hardware and how many instances you have," Solomon said. "We want to automate that chunk. We want to take every action that is complicated and error prone and make it heal itself."

MySQL also is not very efficient when used in a large deployment. Typically, each connection to MySQL requires its own thread on the server. This approach is not feasible at the scale of YouTube's operations, however. "Running tens of thousands of connections is not really viable," Solomon said.

The company's engineers, however, have been reluctant to try to change the core MySQL code itself, noting that making changes to the complex and somewhat difficult-to-understand code can often result in unanticipated effects. "It is not straightforward. Just when you think you know what you are doing, that's when you start getting in trouble," Solomon said.

So Vitess a tool developed in Go was created to run in conjunction with MySQL to offer additional management capabilities. The Vtocc component, for example, consolidates thousands of incoming SQL queries into a smaller number of batches so MySQL can take fewer resources fulfilling these requests. Vtocc also parses queries so they can be executed more efficiently, and reduces the work caused by duplicate queries by reusing the results from one query to satisfy the other identical requests. Using Go has allowed YouTube developers to be more productive than they would have been using a more traditional language, Sougoumarane said.

Go code compiles quickly, he said. The 30,000 lines of code in Vitess can be compiled into binaries in about 30 seconds. And, thanks to a rich set of libraries, many tasks do not require that much programming. For instance, Sougoumarane wrote a 105-line routine that periodically trims log files, functionality that couldn't have been written in as few lines by using C or C++.

"That's how expressive Go is," Sougoumarane said. "The language features are well-thought-out. They help you compose things in a much more elegant way than traditional languages." Sougoumarane also praised Go's concurrency support, vital for use in multicore processors. "You don't have to worry about managing threads. Go manages them for you," he said. Youtube is currently being re-written in Go from Java, C++ and Python. It is funny to see how Go is taking the place of not 1, not 2 but 3 programming language!!.

Purpose of Go.

Go was developed for chiefly 3 purposes which should ring in every developer who wish to learn the Go language. This 3 purpose is what makes it have the features of 3 languages. There are:

  • Effective Compilation.
  • Efficient execution.
  • Ease of programming.

    From the issue Google had with Youtube , those issues from the above were solved by this Go features which in turn has set Google at peace has it has hit a gold mine called Go.

Meanwhile, Google had become frustrated by the undue complexity required to use the languages that worked with to develop server software. Computers had become enormously quicker since languages such as C, C++ and Java were first developed but the act of programming had not itself advanced nearly as much. Also, it was clear that multiprocessors were becoming universal but most languages offered little help to program them efficiently and safely.

Google decided to take a step back and think about what major issues were going to dominate software engineering in the years ahead as technology developed, and how a new language might help address them. For instance, the rise of multicore CPUs argued that a language should provide first-class support for some sort of concurrency or parallelism. And to make resource management tractable in a large concurrent program, garbage collection, or at least some sort of safe automatic memory management was required.

These considerations led to a series of discussions from which Go arose, first as a set of ideas and desiderata, then as a language. An overarching goal was that Go do more to help the working programmer by enabling tooling, automating mundane tasks such as code formatting, and removing obstacles to working on large code bases.

A much more expansive description of the goals of Go and how they are met, or at least approached, is available in the article, Go at Google: Language Design in the Service of Software Engineering..

What is Go used for?

Go can practically be used for anything in the programming world but due to it being a new language there are very few liabries and frameworks to support some usage but Go is efficient just as it was created to be. Below are some things Google Go can be used for :

  • Networking. -http, tcp, udp.
  • Concurrency / Parallelism.
  • Embedded Systems.
  • Automation, command-line tools.
  • Crypto/ Blockchain.
  • image processing.
  • Backend Web development.
  • Artificial intelligence
  • Machine Learning.
  • Cloud services.
  • Big Data.

    Companies Using Go.

    Since the creation of Go in 2007, it has gained wide popularity and usage. Go has given companies the reason to love them as they can run large data and programs without ever worrying for App crashes, they can make products faster as Go offers ease of programming, their apps are faster with Go's efficient compliation and speed. Go has been trusted by many Big companies in the world. Below are some major companies using Go.
  • Google.
  • Youtube.
  • Docker.
  • Amazon for AWS.
  • Jumai Foods.
  • Alibaba.
  • Xiaomi.
  • Kubernetes. See more list at Companies using Go.

Writing Hello World in Go.

Go boasts of ease of programming which I will show below, it is also a statically typed language but nevertheless. Go is Fun. Since we don't have Go installed yet on our local machine, we can use a great tool provided by Go to get started as quick as possible.

Visit Go Playground. Clear the default code there and enter the code below.

// This is the entry point of any Go application.
package main

// This is to import the Formating Package that allows printing of strings
import "fmt"
// Declare a function.
func main(){
// use the format package we imported
            fmt.Println("Hello World")
}

Now press the Run button and you should see :

Hello World

Did it Run correctly? Yes? Good. No? Check the syntax very well, note that Go is statically typed and doesn't agree to errors.

Resources to learn Go.

Just as I would advice any developer, the best resources of any language are the language official Docs. But below are some amazing content that will get you started in Go.

Was the Article helpful? Kindly leave a comment below and a love for me. I would be publishing next on Declaring Variables in Go. This is just an Introdution and a history of Go. Kindly Suscribe to the newsletter to get alerted when I publish more articles on Go.