Why Go?

In this lesson, we'll explore why Go is a great language in general and how many of its properties are important for command-line programs.

In this lesson, you’ll first see a simple Go program, and then we’ll dive into how Go is different from other modern languages and what makes it special. Finally, we’ll introduce the Go mascot.

Show me the code

First thing first, let’s see some code. This is my version of “Hello, world”, and I call it “Yeah, it works!” because I’m always amazed when any program actually works.

package main
import "fmt"
func main() {
fmt.Printf("Yeah, it works!")
}

Go is unique

Go is special in this day and age. What sets it apart is its simplicity and pragmatism. Most of the successful new languages are built on top of established platforms with formidable runtimes like the Java platform, the .NET platform, or JavaScript. For example, Scala, Kotlin, and Clojure are built on top of Java, Typescript is built on top of or compiles to JavaScript, and F# is built on top of the .NET framework.

Go, on the other hand, is a fresh breath of air in its originality. Or is it? Go often reminds people of the simplicity of C, but with the benefit of all the hard-learned lessons of the last fifty years of cumulative programming and language design experience. This is in striking contrast with C++ that took simple C as a foundation and evolved to become a monster of complexity.

Rust is also an interesting original language, but it took another path of more power and less simplicity.

Here are some of the features whose combination make Go special:

  • Multiple return values from functions
  • Capitalization of names determines visibility (public, private)
  • No exceptions for error handling
  • Interfaces, but no classes
  • Strong concurrency support with goroutines and channels
  • Strong tooling
  • Opinionated about formatting
  • Can generate standalone binary
  • Built-in package management

The surprising productivity of Go

As you’ll soon see, Go’s simplicity and lack of error exceptions lead to code that is more verbose than Python or Ruby. However, I was pleasantly surprised when I started working with Go and realized that Go is actually pretty fun to work with. Yes, you write more code, but, it is easier to keep the entire language in your head. You don’t need to look up things every couple of minutes, and the explicit code is also very easy to read. Go intentionally drives you to write simple, non-clever code.

The primary factor that makes Go super productive is its insanely fast compiler. You can make small changes and re-run your program without taking a ten-minute coffee break. The quick edit-test-debug cycle is the cornerstone of productive development, making Go the fastest to compile language I’ve encountered by far.

The Go mascot and the Go community.

The Go mascot is a cute little gopher.

Go community members like to call each other “Gophers”, and the main Go conference is called GopherCon.

Conclusion

In conclusion, Go is a simple yet exciting programming language. It has a lot of momentum behind it because it just works. Therefore, it is especially great for command-line programs because it generates high-performance native executables and doesn’t require any runtime or external dependencies. It’s also a very productive language, which is important for command-line programs that often don’t get the same amount of attention as bigger systems.

Quiz

1

What makes Go so productive?

A)

Insanely fast compiler

B)

Comprehensive type system

C)

Developed at Google

Question 1 of 30 attempted