Skip to main content

Command Palette

Search for a command to run...

Why Go!

Updated
2 min read

First of all, why Go?

Go was created in 2007 at Google for following reasons

  1. Slow Compilation: C++ and Java code at Google was too slow to compile. They needed something that could compile quickly

  2. Complexity: Existing languages had grown to become too complex. They needed something that’s simple.

  3. Concurrency: Languages such as C++ and Java made concurrency hard to manage.

Go brought some advantages as well

  1. Tooling: Go has great tooling support (fmt, go test, go doc)

  2. Garbage Collection: Go’s GC makes memory management simplified.

  3. Goroutines: Light weight threads with multiplexing.

So did Google replace all its code with Golang?

The answer is NO!

Many of the languages (specifically Java) that were complex and that didn’t supported features such as concurrency, now they do, and they have pretty much simplified things.

So why Go?

Because Go is still different. Go needs minimal setup over general purpose languages like Java. Go is still fast to compile, faster to execute and fast to ship.

If you compare Go with scripting languages like Python and Javascript / Typescript, these scripting languages did offer rapid prototyping since the beginning. Go still has advantage over them because of concurrency.

If you compare Go with C++, the basic reason of using C++ was speed. However Golang is able to deliver the speeds relative to C++ with additional features and a different programming paradigm.

So Go is best of both worlds and hence you should be using Go.

Today, Javascript tops the charts because of it being heavily used by browsers and in web development. Java dominates the MNCs and legacy setups. Python dominates the AI space as well as backend. Go is slowly catching up being relatively new.

Go sits right between Java, Python, Javascript and C++. Go is a multi-paradigm (Imperative, Concurrent, Procedural) programming language.

Composition is a core philosophy of Go. Composition is basically building complex behavior by combining simpler types or functions. Composition is an alternative to Inheritance where you would combine multiple classes to create a complex behavior.

Go suggest instead of creating hierarchies of classes, just compose small reusable pieces of code.

type Animal struct {
    Name string
}

func (a Animal) Speak() {
    fmt.Println(a.Name, "makes a sound")
}

type Dog struct {
    Animal // embedded
    Breed  string
}

In next topics, we will cover how we can use Golang to create highly scalable applications.

Go Programming Language - Basic To Advance

Part 5 of 5

This series is all about Go Programming Language. We will start from basic features and then discuss about creating large projects with best practices and at the end also cover system design and design patterns using Golang.

Start from the beginning

Array vs Slice in Golang

Arrays Golang is statically typed compiled language. So it can be compared with languages such as C++. Now, C++ has arrays however those were not with dynamic length. However we also have collections using which can make dynamic arrays. Similarly, in...

More from this blog

P

Programming, System Design and AI | Latencot

15 posts

Hear, you will read all about tech and tech updates. From writing code to building AI systems, we'll talk and share about everything.