5 Problems I Have with Golang

5 Problems I Have with Golang

I want to talk to you about the problems I have with the Go progrmamming language. Specifically, I'll be going over 5 problems because it just so happened I could only come up with 5. So I've been using Go for various projects for about a year now and I've come across a lot of issues with it.

Hey guys, welcome back to another video. So some of you wanted me to do a video comparing Rust to other languages like C and Go. But I haven't thought of enough to talk about. These languages all have their advantages and disadvantages. And depending on what you're developing or how you like to program, you will find some more appealing than others.

Find me elsewhere: Instagram: https://www.instagram.com/kamiyaa91/ Github: https://github.com/kamiyaa/

Books I've been reading: The Lean Startup by Eric Ries: https://amzn.to/3hwbg3J Late Bloomers by Rich Karlgaard: https://amzn.to/2DcmCLo Disclaimer, these are affiliate links. If you make a purchase, I will receive a commission.

But today, I want to talk to you about the problems I have with the Go progrmamming language. Specifically, I'll be going over 5 problems because it just so happened I could only come up with 5. So I've been using Go for various projects for about a year now and I've come across a lot of issues with it. Now these issues doesn't mean I'm saying Go is a bad language and it does not mean I won't use Go in the future. It's just things that make me want to use the language less because it doesn't feel as nice to program in. And I'll be going through these issues from least impactful and to more

impactful ones that I think could be genuine issues.

  1. Inconsistent Syntax These are honestly not that bad, just really tedious and not necessary. Things like:

    • having to use := when you first initialize a variable
    • tuples need to have brackets around them in the function header, but must not have brackets in the return statement
    • having to use a commas or periods to indicate a new line
    • can't use commas inside a struct definition, but need commas inside struct instantiations
  2. String, Print, Formatting APIs Golang follows the same conventions as C, using %s, %d, %c and so on to indicate what type you want to print. I don't think keeping this was necessary and they could've opt-ed for a much better solution. For example, in Javascript, we have string interpolation using `${var1} ${var2}. And in Python and Rust, we ditch the % formatting for a generic {}.

  3. No generics I understand this was a conscious decision made by the creators because they wanted the language to be simple, so they left out things like macros and generics. Which kind of sucks but you can bypass this for the most part using interfaces

  4. Namespacing I think the namespacing capabilities in Golang is pretty weak. They impose a lot of restrictions and you can't do things like referencing packages inside packages or having associate functions. So if your package has more than one struct and you want to create constructor functions for them, then you will need really long function names so they don't conflict with each other. But again, you can work around this with a builder patten.

Honourable mention: $GOPATH environment variable This caused a lot of headaches when Go first came out because it was mandatory. Developers was forced to develop under the GOPATH and dependency management was a pain. But fortunately, with recent Go releases and the use of a go.mod file, this is no longer the case.

  1. Error handling The last problem and I think this is the most important one, is Go's error handling. Error handling in Go is explicit. You have to manually check for errors with if statements just like in C. Now on paper, that seems like a good idea to have to explicitly handle errors. This way, we won't have to worry about unhandled errors like with exceptions in other languages. But in reality, its much more complicated. A function in Go would usually return a tuple of two items, the first one being the actual value you want and the second one being an error if anything went wrong. For each of these functions, you have to have an if statement that checks if the error is not nil. If it's not nil, then we know an error occurred and we need to either handle it or return it for our caller to handle. Now again, this sounds like a good idea. But in practice, what ends up happening is that every function call requires an if statement immediately following it before your logic can proceed, because almost always, you don't want your function to handle it and you just wants to keep returning it until some high level frontend code handles it. So your code ends up being really hard to read and understand because its logic has been segregated by long error handling if statements.

Hope you enjoyed the video!

Music: Background music by Pep8: https://soundcloud.com/user-808315049-409100976 Michikusa by PeriTune (Licensed under https://creativecommons.org/licenses/by/4.0/)

Timestamps: 00:00 Intro 00:55 1. Inconsistent Syntax 01:30 2. String, Print and Formatting 02:11 3. No Generics 02:29 4. Namespacing 02:55 Honourable Mention 03:23 5. Error Handling 04:54 Solutions to (5)

golang go

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

What's new in the go 1.15

Go announced Go 1.15 version on 11 Aug 2020. Highlighted updates and features include Substantial improvements to the Go linker, Improved allocation for small objects at high core counts, X.509 CommonName deprecation, GOPROXY supports skipping proxies that return errors, New embedded tzdata package, Several Core Library improvements and more.

Go Tutorial (Golang) - Looping Constructs in Golang | Golang For Loop

In this video we will see the Looping Constructs in Golang. Golang For Loop. Go is an open source programming language which was originally developed by Google. In this Go Tutorial we will Learn Go from the Basics with Code Examples. Go is a statically-typed language.

Golang Array Example | Arrays in Go Tutorial Explained

Golang array is a fixed-size collection of items of the same type. The items of an array are stored sequentially and can be accessed using their index.

Go Tutorial (Golang) 18 - tags in Golang | How To Use Struct Tags in Go

Go struct tags are annotations that are shown after the type in a Go struct declaration. Golang tag for a field allows us to attach meta-information to the field which we can acquire using reflection

Go Tutorial (Golang) - Looping Constructs in Golang | For Range loop in Golang

In this video we will see the Looping Constructs in Golang - Golang For for-range Loop. o is an open source programming language which was originally developed by Google. In this Go Tutorial we will Learn Go from the Basics with Code Examples. Go is a statically-typed language. Go has a syntax similar to C. Go has built-in concurrency.