7 Reasons You Should Try Go

Β· 1037 words Β· 5 minute read

This article is written with 20+ years spent in development, 10+ years actively writing in Java, 7+ years actively writing in C# and 3+ years actively writing in Go.

This article is a personal opinion.

This article advocates you, to try and use Go language.

Speed of development πŸ”—

When I am about to write a piece of software nowadays (and I can surely write it in all three languages), I will always choose Go.

I will write the final software in less time, using Go. The code is more readable, less abstract, more “to the point”.

When you are writing Go code, you are doing exactly what you should do. Writing the production code. You are not writing classes, subclasses, getters, setters and a bunch of code, that actually does nothing. When you are writing Go code, you are writing code, that does something. You are not writing code “for code itself”.

In the end you are writing less code, with less thinking about what it is doing, hence the speed of development goes through the roof.

Side note: From my personal experiences, code written in Go is the most straightforward to read, from those three languages. And I have got this tested. I wrote once a piece of software in C#, Java and Go, using theirs best techniques. And then I asked my three colleagues a simple question β€œWhat is this code doing?”. They were lost in Java and C# (being PHP developers), but I got the answers for Go with all of them.

Speed of deployment πŸ”—

This is the second most useful thing I personally like in Go. I tend to make changes all the time. And I like to see the results of those changes immediately.

Go code builds so quickly, I have no problem making changes, as many times, as I want. And I don’t care, how big the project is.

Also, deploying binaries for all three major operating systems? Piece of cake.

One way of doing things πŸ”—

You will appreciate this, when going back to your code after few months, or years. By decision of its creators, Go code is formatted the same way, everywhere you look. That means, you have (almost) no problem understanding any Go code, you will see.

As an example, being a C# developer, you can convert integer to string in about 7 different ways. You can do a lot of other things with even more options.

Can you imagine, if you combine all those β€œdifferent ways of doing” small things, like converting integer to string, how many different variations of written code you have? I still have problem understanding Java and C# code of other developers, but I can actually instantly see, what a piece of Go code, unknown to me to that time, is doing.

The simplicity of Go is one of it’s strengths, you will appreciate not instantly, but over time.

Binaries size πŸ”—

As a developer, you should always try to have as small binaries as possible. Smaller size means faster deployment. Smaller size means less network transfer. Smaller is simply better.

In our company, we use Docker as a runtime environment, so we “pack” our software into Docker images. We have plenty of images in our Docker Hub repository, so we can easily compare their sizes. Of course we use the best techniques, to have our images smallest possible, no matter the language.

We don’t use Java in Docker, so no comparison here, sorry.

But we use C# and Go. Comparing the same functionality.

C# images are 40+ MB of size. Go images are 3+ MB of size.

You can learn more on that in this article: Run Go service in Docker and reduce executable size by ~73% as a bonus (i will link it later)

Standard library πŸ”—

This was something, that came over time. When we started using Go, we started searching for libraries. Because you need libraries to do a different things, right?

The opposite goes for Go, which has an incredible standard library: stdlib. You can write almost anything using just the standard library. Less libraries β€” here modules β€” means less third party code you have to look about. I wrote about this in this article: Lessons Learned While Developing Enterprise System Simple to implement strategies (link later)

Go routines πŸ”—

This was an instant love for all of us. We are developing software, that is heavily network base. Communication with this device, communication with that device, communication with …, you get the point. And we like to distinct between all of those devices.

That means, threads are something we use a lot in our software. If you ever use threads, maybe you remember, how you learned it and what work you have to do.

In Go, if you want to run a function() in a “thread”, all you have to do is add go in front of it, like this go function().

That’s all. When I first saw it, I was like: “And that’s all?”. Yes, that is all.

Also, do you know, that β€” by default β€” one Java thread allocates about 1MB of memory, C# thread also about 1MB, but Go routine only about 2kb of memory? How awesome is that?

Web server πŸ”—

This was an instant love, especially for me. You can run a simple web server, listening on port 80, using code below.

Then just put your html, css and javascript files into that data folder and you are good to go.

If you want to see a complete tutorial, this article is for you. Go service as a web server, Serve HTML, CSS and Javascript files (later)

Summary πŸ”—

When I first learned about Go, I was not interested. I thought, I was using the best languages in the world (meaning Java and C#), backed up by big companies.

But then I read something about go routines. That attracted my mind. And when I saw, how easy it is, to run a web server, I was hooked. I started to use Go and never looked back. Go became my best language.

I advice you, to give Go a try.

You will be amazed, how productive you can be.

waffarx cash back