Skip to content

Come back to golang?

DUONG Phu-Hiep edited this page Apr 29, 2024 · 4 revisions

In 2018, I tried Golang - the rising star, there are many things I love about this language but in the end, I did not go all out. Here are some dissatisfaction which prevented me to promote Go as my first choice programming language (in 2018)

1) Ugly codes: too verbose

You often have to type more codes than other languages to do the same thing. The main reasons are

  • The language is minimalist, no sugar syntax
  • Missing generics Support
  • Error Handling: error as a value so codes are usually bloat with if err != nil {..}

Ironically all of these things are what Go developers are proud about..

  • The language is keep minimalist, no sugar syntax => any developer can quickly learn the language and be productive in a very short time.
  • Missing generics Support => there was no reason for support Generics and we can use the powerful go generate instead
  • Error as a normal return value which should always be handle properly

=> Go Generic is here!!!!!! big Thumbs up, the only thing missing is Sugar/short syntax for Error handling

2) GOPATH and GOROOT and dependencies management

Go was really bad at this. Before the arrival of "go mod".

3) Scare drivers / library support

Prior 2018, you won't have the driver of mongodb for Go. Not only mongodb. Most things I needed did not support Go: ORM, database scaffolding tools, swagger, structured logging with seq, prometheus...

Evens if I found something it were usually in alpha state and a Go SDK were usually not the first class supported language for them.

Come back to GO in 2022!

I could live with (1) or (2) and get used to it. But the point (3) was the real blocker. So I decided to stop with GO. Now in 2022, I just briefly monitor Golang and I think that the moment is arrived to give it another try.

Hopefully Golang will become my first language of choice on the same level as C#


DI in GO

https://uber-go.github.io/fx/get-started/

  • Question: objects life cycle (scoped, singleton..)?

try / catch / finally in GO

Similarity:

  • panic ~~ throw (raise),
  • recover ~~ catch
  • defer ~~ finally

Differences:

no way to have multiple sub "panic/recover/defer" in the same function. the "try" always start the function? "panic/recover/defer" impact the execution flow, but is not designed for developers to change or to control the excecution flow as "try/catch/finally"