This article is a beginner guide introduction to Golang and 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 the creators of Go?
- Why Go?
- What is the purpose of Go?
- What is Go used for?
- What companies use 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 performs 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 is 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 its website () and not go.org which was not available to Google.
Who Are The Creators Of Go?
Let's take a look at the genius behind this amazing language. These are the people who made the Go language - ideally, I love to call them the 'Pioneers of Go'. They include:
1. 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
2. Robert Griesemer - Studied under the creator of Pascal. Maybe this is where he got his amazing skills of creating amazing things.
3. Ken Thompson - solely responsible for designing and implementing the original Unix operating system.
- He invented the B programming language, the direct predecessor to the C programming language.
- Ken helped invent the C programming language.
Wow!!! Great people indeed. From the above analogy of the people who came together to make this amazing language in Google Labs, it is expected to be one hell of a language and is very efficient for anyone to use. The fact that Google is backing it is a great encouragement for anyone looking forward to learning this language.
Why Go?
You might ask "Ok, why would I learn Go? Aren't there a bunch of other languages out here?". 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 its 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. This functionality 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 languages!
What is the purpose of Go?
Go was developed for chiefly 3 purposes which should ring in every developer who wishes to learn the Go language. These 3 purposes are what makes it have the features of 3 languages. They 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 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. 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 codebases.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 .
What is Go used for?
Go can practically be used for anything in the programming world. Due to it being a new language, there are very few libraries and frameworks to support some usage. However, 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.
What Companies Use Go?
Since the creation of Go in 2007, it has gained wide popularity and usage. Go has given companies the reason to love them because they can run large data and programs without worrying about App crashes. They can make products faster as Go offers ease of programming. Their apps are faster with Go's efficient compilation 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 a more complete list at .
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 . 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 :
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 advise 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.
- This Blog - Visit this blog and get a beginner-friendly approach to Go.
- .
- .
- . - Summary of the Original Docs.
- .
- - Udemy Course.
Previously published at