4 minutes read

A major tool of computer science is programming languages. We use them to develop computer programs. In the modern world, there is a wide variety of programming languages, every one with its own community of fans. Let's find out what makes Go unique and what's there to like about this language.

Go programming language?

golang logo

Just a very brief history note if you're curious:

In 2007, Google began developing the Go programming language as an internal project. Two Unix luminaries, Rob Pike and Ken Thompson, designed the original. Two years later, on November 10, 2009, the software was released under a liberal open-source license. A version of Go 1.0 that was ready for production was released in March 2012. Google's team of designers worked on the Go project along with Russ Cox, Andrew Gerrand, Ian Lance Taylor, and others. And thanks to all these people, you've got the chance to learn this programming language.

stages of golang emergence

Go is also called Golang, the same name as the Go programming language; the "Golang" moniker arose because the website (go.dev) was originally golang.org. We will use both names interchangeably throughout this topic.

Advantages of Go

Go has a clean syntax. The table below displays a syntax comparison between Go and Java when declaring and initializing variables.

Go versus Java

Go

Java

package main

func main() {
    a, b, c := 1, 2, 3 // a, b, c have the 'int' type
}
public class Main {
  public static void main(String[] args) {
    int a = 1, b = 2, c = 3;
  }
}

Go is a pragmatic language: its main purpose is to solve real-world problems. You can see it in the below examples:

  • The original intent of Go was to be used in the server-centric world of web servers and storage architecture. Thus, the decision was made to make Go a programming language compiled into native code. Go programs usually execute very fast and have a low memory footprint. That's why you can use this language as a system programming language.

  • Golang excels at handling massive concurrency and making event processing easy. That makes it a good choice for game servers and IoT solutions. Another helpful link to learn about successful examples in Go is the Go Wiki.

  • And finally, you can use Go as a general programming language. It is a great tool for developing and solving text-processing problems.

Go mascots working

Take a pause to look at how Go mascots work in different roles. Inspired by Renee French's design

The language supports a range of programming paradigms, including imperative programming, object-oriented programming, procedural, and functional programming. The Go FAQ contains an explanation of these designs by the Go team.

Disadvantages of Go

While Go has many advantages over other programming languages, it still has some disadvantages you should be aware of when learning it:

  • Go's standard library lacks some functions compared to other languages. For example, there is no built-in function to find the biggest number in an array of numbers, so you would have to implement it manually.

  • Go's standard library doesn't support GUI programming by default, which is an advantage of other programming language libraries, such as the Java standard library.

  • Go's standalone binaries are large because they require the embedded garbage collector and the entire Go runtime as well. The "Hello World" program might consume 2MB in file size.

Gophers by French's gesign

Gophers are just simple beings. Inspired by Renee French's design

First Go example

Now that you've been acquainted with the Go language, you can follow these steps to install Go on your computer.

Once you have finished installing Go, we can take a look at the first code example. It prints the "Hello Golang" string to the terminal (suppose this example is contained within the main.go file):

package main

import "fmt"

func main() {
    fmt.Println("Hello Golang") // prints "Hello Golang" to the screen
}

When we write comments in Go, we use the C++ style: // for one-line comments that we usually place at the end of the code line, and /* ... */ for multi-line comments.

The Go programming language is organized into packages, and every Go program should have the main package containing the main() function, which serves as the entry point for the program (the function that is executed first).

Now click the run button in JetBrains' GoLand (or IntelliJ IDEA) or run the program directly in the terminal by executing the go run main.go command.

run the program

hello golang

Congrats! You've just used Go for the first time.

Conclusion

Here is a reminder of what we have covered so far about the Go language:

  • A brief description of Go;

  • What it can do;

  • Reasons why Golang is so popular in computer programming;

  • Learning how to write simple code in Golang.

Once you understand Go's most basic concepts, you're ready to go further with your exploration.

408 learners liked this piece of theory. 11 didn't like it. What about you?
Report a typo