Go. A Frontend Developer Review.

iamfrntdv

Eduard Pochtar 👨‍💻

Posted on April 12, 2020

Go. A Frontend Developer Review.

cover
It's been few months since I've started to learn Go and I already have something to share. This is a small review of Go from a frontend developer point of view. I'll describe things I liked and things I didn't like.

Why did I started to learn Go?

I believe that exploring new things helps to bring new ideas, inspiration, be more creative, solve some problems in a different way.
I'm a frontend developer for 10 years and I didn't learn any other programming language besides HTML, CSS, JavaScript. So I thought It's time to learn something new. I was thinking about some other programming languages but Go seemed to me more attractive. Maybe in the future I'll learn some else programming language.

What is Go?

Go is a statically typed, compiled programming language developed by Google. It has similar to C syntax but has some extra features like memory safety, garbage collection, structural typing and CSP style concurrency. The Go goal is to help building simple, reliable and efficient software. And it's open source.

The Bad Side.

Let's start with the bad things. As for novice in Go the hardest problem for me is community it's small compared to frontend and some times it's really hard to find some solution to some problem, lack of best practices. But this can be changed in the future.

One of the things I like about frontend or related open source projects is that developers, not just write good documentation, they make everything to make their projects more attractive. As for Go open source projects, of course there are some projects with good documentation, but there are still a lot of projects that miss documentation which is very critical to newcomers. Very often I was turning away just because didn't understand what it was about or how to use it.

The Good Side.

Performance.

One of the biggest advantages of Go is performance. Go is very efficient programing language, of course it depends on a lot of things and there is always opportunity to make things go wrong. But by default Go requires very small amount of resources. For example I have some side project built with Node.js, while it's running it requires about 120mb of memory and as for Go it's about 10mb of memory for almost the same amount of features. It's a big difference.

Go is also multi threaded. This give a huge performance boost compared to Node.js which is single threaded. This limitation of Node.js makes it impossible to create super efficient and faster tools (build, task runners, etc) for developers. And here is great example of this Battle for the Bundling time: esbuild — a JavaScript bundler and minifier written on Golang
Of course it's not hard to understand that for frontend developers it's much easier to develop tools in the programming language they work everyday.

Simplicity.

Go has some new paradigms I had to change despite this Go I very simple programming language. As I mentioned before Go is statically typed but you don't have to define each time. You can define types dynamically with :=.

One of the first question I had when I've started to learn Go was "What about object?", "Does Go has objects?". Well yes and no. Go has kind of objects - structs:

struct {
    x, y int
    u float32
    _ float32  // padding
    A *[]int
    F func()
}
Enter fullscreen mode Exit fullscreen mode

I can't deny or confirm that this makes Go simpler, it's just another kind of paradigm you'll have to learn.

Pointers - another paradigm I had to learn. It's maybe similar to references in JavaScript, but you have to define that you would like to use a pointer:

b := 255
var a *int = &b
Enter fullscreen mode Exit fullscreen mode

You can also to return multiple values in functions:

func myFunc(num int) (input int, calculated int) {
    calculated := num + ...

    return input, calculated
}
Enter fullscreen mode Exit fullscreen mode

Packages.

I really like package system in Go. Exporting and importing variables and functions is super easy. Package can contain multiple source files but there is no need to import each file individually. It would be enough just to import the package and use required of code. Every name of function, variable that starts with capital letter can be imported from another package.

Build.

If you where working with Node.js you may already know that you don't have to build a Node.js app, it would be enough to start it and it will run. But in most cases you probably will use some packages and this will require you to install them. And the problem is that you can't install those packages and them copy or deploy them to some other machine or server. All the packages should be installed on the system where the Node.js app will run. This makes CI/CD of Node.js apps a little bit more complex. Another thing to keep in mind that node_modules very often has additional files like documentation, images, audio, video files, whatever which can require a lot of space. In some cases it can be very critical and you will have to handle this on your own.

As for Go, in most cases you will build Go app in one executable file or few executable files for different OSs. Yes, you can build Go app on one OS for another OS. And deploying one or few executable files is much easier than dealing with node_modules.

Conclusion

Compared to frontend programing languages like JavaScript Go has some new paradigms, but that doesn't mean that Go is worse it's just a little bit different. It's very efficient, it's simple enough, it has great package system, it's perfect fit for build tools and task runners. It's a great alternative to Node.js. You can build Go app for multiple platforms which makes it easy to deploy it.

If you would like to learn some other programming language you definitely should try Go.

💖 💪 🙅 🚩
iamfrntdv
Eduard Pochtar 👨‍💻

Posted on April 12, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related