top of page

Quarantine and GO (golang)

  • Writer: Carlos 青木 Thomaz
    Carlos 青木 Thomaz
  • Apr 12, 2020
  • 2 min read

Already week-3 of quarantine (social distance) and I'm still stuck in São Paulo. Luckily I'm with my family, so one less thing to worry about. At least we are all together.

Finding stuff to fill the time-gap (not that I have a lot of spare with a 1.5 year old kid around), but I've decided to dig into some programming languages and understand what framework would be interesting to learn.

Got a good surprise with GO (aka golang). My first impression, some years ago, wasn't that fun, but having the patience to understand the language better turned to be a fun surprise.

Some stuff that I really loved and kind of missed in Python:

Pointers. Not that I'm a hardcore C or C++ programmer (in fact I know just a little bit academics of C/C++) but writing some python scripts recently, I found myself short handed not being able to use pointers as we could do in C. GO has pointers but has no Pointer's Arithmetics which for me is great! At least for what I need, access memory space is the only necessary thing.

Garbage Collection. Go is a garbage collection language and has been designed to be highly optimized. So no need of mallocs and free which for me is the probably the best design decision. Further, I would like to post some comparison's I've made between C and GO on what regards garbage collection and memory management. I have to be honest, this has ever been a pain on my back. So now I'm healed.

Structs. Oh gosh... gotta love structs. This is something that simplify a lot. The other day I was creating a small routing in python where my data structure required a little more than just a tuple, but nothing too fancy. Something that in C would be:

struct foo {
    int index, a, b, c
    char[8] e
}

So, I've done a dictionary of dictionaries implementation in python which for me sounded not really the best. Found out this week that GO has structs in almost exactly same way that C implements. IMHO is a lot easier to read and understand than python syntax.

type foo struct {
    index int
    a, b, c int
    e string
}

Syntax. I love the fact that GO isn't space based indented. The curly brackets "{ }" makes a lot of more sense than checking indentation.

Couple things I don't quite like either.

I do understand the purposes of designing a server based language that should fit better in the modern days of everything-web-based but don't quite love the directory structure and skeleton that needs to be created. It's overkill in my opinion.

The fact of create a single binary container is nice, but once again that doesn't really make very simple for small stuff.

I know I will find a lot more pros and cons. This is not about to technically explain the syntax and semantic details of the language. It is more about just to write down couple feelings. Overall, I'm confident this will help me with some of my goals. And, as said earlier, I plan to post some small examples comparing to other languages (mostly compared to python). Let's see....

Comments


  • facebook
  • linkedin
  • instagram

©2020 by Carlos A. 青木 Thomaz.

bottom of page