You Better Get Going with Go

“I think Node (.js) is not the best system to build a massive server web. I would use Go for that. And honestly, that’s the reason why I left Node. It was the realization that: oh, actually, this is not the best server-side system ever.” (HS, 2017) This quote is by Ryan Dahl the author of Node.js.

Well, this is basically my story too. I left Node.js as well, and now I use the Go Language (Golang, Go) as my backend technology of choice. Although Node.js will always have a warm place in my heart, if you are looking for the best backend technology that is out there, I fully recommend Golang. Let me tell you why.

The motivation behind the creation of Go was that currently, there are many programming languages available. Each has its own pros and cons. There are some languages that are efficient, but not simple, like C and C++. And, on the other hand, there are simpler languages that are less efficient, like JS and Python.

But, a programming language should be perfect—both efficient and simple, right? Go is both, and a lot more. Let me elaborate a little further on why that is.

Go syntax is something between C and Python with advantages from both languages. It has a garbage collector that is very useful.

  • It does not have objects, but it supports structures (structs) and any type can have a method.
  • It does not support inheritance, but does support compositions and interfaces.
  • You can have a pointer to a variable, but at same time, you don’t have to worry about referring to its methods.
  • It’s statically typed, but it’s non-strict because of the type inference.
  • Its package-based code management reduces the number of code lines.
  • And last but not least, Go has a simple concurrent model.

Let’s dig into some examples of the simplicity, but awesomeness of Go.

  • Swapping between variables is simple:
    • b, a = a, b
  • It allows you to import a package directly from GitHub or any other source manager:

o    import “github.com/pkg/errors”

  • By starting a Goroutine, it supports concurrent routing:

o    go runConcurrently()

  • Allows you to refer to a method of instance of some type, no matter if it’s a pointer or the actual instance:
    • instance.method()

Thanks to the Go dependency model and its memory management, the compilation is very fast when compared to low-level languages, and even more so with high-level languages.

Go’s runtime performance is similar to C++ and C, making its performance quite notable.

In the context of scaling, Go is much faster than popular competitors thanks to the Goroutines model as you can see in the figure below.

When comparing Goroutines to Java threads, Goroutine threads consume ~2KB, while Java threads consume ~1MB.

Go is an open source language with wide adoption and a fast-growing community. On the web, you can find lots of free and useful packages and many Q&As, FAQs, Tutorials, etc.

According to 2019 stack-overflow survey among developers, Go is one of the most popular languages. 8.2% of the survey respondents are programming in it, and 67.9% of the respondents mentioned Go as their most loved, dreaded, and wanted language. Go scored the highest rank (93% of the respondents) as a preferred language in a 2019 survey by Golang within Go developers, and as you can see in the Figure below, Go is growing in popularity.

 

In addition to that, Go is super easy to learn. Because of its friendly syntax and the great “Tour of Go” (that takes about two days to complete and covers all the basics you’ll need to get started programming in Go), after completing the tour, you will feel very confident with the language. When you start using the language, coding with it will become pretty easy overall. And after about two weeks of using it, it will likely become your preferred/native language.

Looking to quickly increase your knowledge of Golang security? Check out our Intro to Go Language guide!

 

So, hear this Gopher out!

You Better Get Going with Go.

Reference

HS, P. (2017, October 03). Episode 8: Interview with Ryan Dahl, Creator of Node.js. Retrieved July 07, 2020, from https://mappingthejourney.com/single-post/2017/08/31/episode-8-interview-with-ryan-dahl-creator-of-nodejs/


*** This is a Security Bloggers Network syndicated blog from Blog – Checkmarx authored by Stephen Gates. Read the original post at: https://www.checkmarx.com/2020/08/18/you-better-get-going-with-go/