Why I chose Golang(Go)

Nixon Kosgei
7 min readJan 5, 2021

Today I feel compelled to share my story on why I choose to switch to golang as my primary programming language after years of PHP. I just woke up from a 2hour nap(more like a deep sleep actually) and all I could think of is why golang and decided to write about it.

Golang is actually gone, but you know. because of search engines, searching go will actually never yield anything. That’s why I made sure the title of this story has both go and golang in it. It's something we have to live with, do I wish, there was a better name? yes. But am I crying about it, I probably Not, at least it's not Iron oxide. because that’s a terrible name. This just goes to show how terrible people in computer science are terrible at naming things. In my opinion, it's because of how gender unbalanced we are, with so few women in this field we lack opinions from 50% of the human race.

But What is Golang you ask?

Well, it's just another tool initially developed by Engineers at google. but now by thousands of contributors worldwide, thanks in part to it being opensource

Tools like we have C & C++ & C#, & Rust even PHP and so many other tools that we just keep building more and more of them every day. You know what? tools aren’t actually any better, tool A can do what tool B can. Sometimes I ask myself, can we just have one tool? but then I ran into people on the streets when I leave the safety of my house and realize how different people are, I mean look at the transport sector, some drive on the right(including me) while others are on the left. Some measure in feet, we here say meters, the electric plugs and so many many others, including what to have for dinner alone when am with my family is a hustle to choose what to actually eat.

From the above, we learn that we humans are all different and we can never actually come to an agreement on anything that’s why we have elections to try and bring cohesion. It's not a problem in our field only but it's everywhere. the solution to all of this is to embrace the indifference. In computer science today this is being done by having different teams work on different modules of a larger software using any tool they like in whatever design they are comfortable in. Thanks, microservice. You’re a savior to all of us(for now).

Golang lives on github.com/golang and the website is golang.org or go.dev. Why do we have to websites? don’t ask me but both are well updated regularly, we, however, seem to be moving to go.dev lately especially for third-party packages while the official docs remain at golang.org

How I jumped into Go

At the end of 2019, I was on my normal youtube rounds of watching videos hottest at the moment, every major YouTuber uploads a video about tech to watch in 2020. I had about Go in the past but hadn’t really had an interest in it. but at the time, after that video, more and more golang videos kept appearing on my feed. I remember watching Jake Wright’s Golang in 12 minutes video, the sad part is I didn’t actually learn it in 12 minutes but it served as a nice intro to know the look and feel of the language.

From then I got into a bit of Golang towards the end of 2019 and then stopped after a while because you know...Life. I got busy with my actual work and projects I was working on to actually take a look at it.

Enter the Global Pandemic

2020 was for sure not good for most people all over the world Including me, but for now, let’s just focus on the positive side. One of the biggest changes to the business in Nairobi was working Remotely, This was something I had wished for but before covid, it wasn’t actually even attainable to any level because to most Human resource, you have to be seated at your desk every working day to register that you’re working.

In Kenya, the 1st case of Covid was on 12th March 202 and that’s the last day I went to the office till today(FYI: am writing this article on My bed on Tuesday at 19:00). Everything had to change, Luckily I had a home office, after making sure I had all the supplies, I locked my front door from the inside and began the best 2 months of my life, leaving only to get fresh supplies on weekly basis after the first month or so, going outside was scary as I really didn’t want to get infect, being young and healthy I knew I would survive it but who knows about the long term effects of it on your body. So I locked my self in my 1 bedroom apartment, alone for about 4 months.

While in lockdown, Work moved really smoothly, no more wasting time in the notorious Nairobi traffic heading to work, waking to prepare for work, or even keeping track of time essentially except for Tuesdays when we had our weekly staff meeting over Google Meet. This meant I had so much time to spare, and all the time I got was devoted to work and finishing my Incomplete projects, Deep down I wanted to show HR that I can work unsupervised and still deliver. Guess what? It worked. I finished all my pending projects in a really short amount of time than expected has I had more time and fewer distractions. It was a dream I have always wanted.

After my tasks were essentially over, I got back to doing small bits of work, more Netflix, and then Golang came back and I run with it.

Learning Golang

My first golang encounter was Jake’s 12 mins of golang I mentioned above, beyond that. I looked into more golang videos on youtube, Downloaded golang and tried it out, Went to a tour of Go and completed it, Tried all the examples on gobyexample.com looked into some GitHub code repositories written in go. basically, I search and filter by language and sort by stars. I tried to pick smaller codebases that are easier to understand, then move up from there. What I have learned is these are essential in knowing how real projects look and feel especially when you’re moving away from the playground and trying to build something.

Why I actually choose Golang

  1. It's a compiled language — Coming from an Interpreted language. The promise of running a compiled code that's built specifically for the platform that’s running on seemed promising, especially the speed gains. no more waiting for PHP to require a ton of composer packages classes and parse them before processing the actual request.
  2. It has everything built-in and actually usable — PHP is so simple, you just write your code, put it in apache webroot, and then bam! Everything works, I remember trying out nodeJS years back(2017 actually) you can’t actually do anything significant with the HTTP server without pulling in express or similar frameworks. Golang had the same feeling for me with the net/http, except it looked a lot like a framework but it's not. This is the case for most built-in packages.
  3. Golang is Simple — It's a small language, anyone can pick it up really fast especially if it's your second language. most concepts are easy to understand but that doesn't mean it's easy.
  4. Concurrency — PHP has none and go has. Thank you
  5. Static Typing — This seems to be a trend lately, even PHP has been adding a lot of this but they are optional for backward compatibility. Not only does it make programming tooling much more efficient and thus faster speeds.
  6. Well, It's cool — Tell anyone you’re a PHP developer and see their reaction, in as much as I love PHP, Its simple and gets the work done. Lots of people despise it. everyone using PHP knows that it has really moved forward since its early days, but people haven’t changed their minds about it, especially on Twitter & Reddit. What's wrong with having another tool! plus it's cool… now I can shout on Twitter while writing my PHP code silently

What I love about Go

Language itself

Go is really cool. It's small, no classes, no inheritance, instead we have structs, they are kind of like objects in JavaScript. It allows you to embed structs into other structs to achieve kind of a similar effect. They call it composable

Maps are perfect, what you would expect from any language essentially

Receiver Functions — It's like a normal function but has access to a struct and all its defined properties via strange syntax that you will grow to love. If you’re into OOP, it's essentially like a class method

I like that there are few global functions like panic and close e.t.c most of the stuff has to be explicitly imported. Less magic for everyone.

Tooling

Goland coming from PhpStorm, was automatic for me as I really love everything Jetbrains. VS code support is really cool too I tried it works for the most part.

In Go, code formatting is really opinionated. It has a built-in tool gofmt implemented in most editors that automatically formats code according to what it thinks is best so that we don’t have to argue about 2space vs 4 vs tabs and all those. There are more high-level linting tools as well, that I don’t have the skill set to get into… what I know is that it's built into my editor or any plugin essential and it serves me right at the moment

Compiling For a Platform

Dear Java developers. Please copy this, You look at Maven, it's everything in one. Am sorry for you guys, this is what made me run away from Java a few years back.

With Just a single command, Go will compile your program really fast and spit out an executable for a platform that you’re targeting, and it's ready to be shipped. This is a dream for development as it rivals the speeds of an interpreted language while reaping the benefits of a compiled language in production

In Conclusion

Go has been really fun🤩 its what every PHP & Python developer should actually look into next. even if it's just for fun and toy projects. You will get to appreciate fixing the errors during development after the product has been released.

If you notice any typos or anything misleading let me know by writing to nkosgey6@gmail.com. follow me on Twitter nixoncode.

--

--