Acquaintance with Go Language

Acquaintance with Go Language

In this post I'd like to share my recent experience from learning Go programming language.

I've decided to dive into Go by taking "Programming with Google Go Specialization" @ Coursera:

https://www.coursera.org/specializations/google-golang

The specialization consists of three courses:

  1. Getting starting with Go
  2. Functions, methods and interfaces in Go
  3. Concurrency in Go

The courses are taught by Prof. Ian Harris from University of California, Irvine.

In my opinion the specialization provides good introduction into Go language, even though I found some of the concepts as very basic.

My Start in Go

Let me start by saying that I’ve spent most of my professional time coding in C# and Java programming languages, and although I feel equally comfortable with both, I must admit that C# is my home court.

We all know that .NET core was a game changer. It allowed to containerize .NET applications and run them on Linux servers. Since its release, the great paper by Microsoft ".NET Microservices: Architecture for Containerized .NET Applications" became my desk-book. It thoroughly discusses architectural design and implementation approaches using .NET Core.

Putting platforms interoperability and even performance considerations aside .NET core undoubtedly offers great programming experience and flexibility.

Since Golang is rapidly becoming the language of choice for building cloud-native and following the saying "doing something once is better than hearing about it a hundred times", I decided to gain some hands-on experience with it.

Go Programming Features

Getting starting with Go was pretty straightforward process: downloaded it from here, and since I already had VSCode, just added a few Go tools and extensions.

After completing a bunch of assignments (and of course the canonical "Hello Go" application :)), I've immediately noticed its unique features (subjectively speaking :))

  1. Is Go object oriented? The answer depends on what language you're coming from. At first glance, Go code doesn’t look much object oriented, but going deeper I understood that Go just takes a different take on object orientation. It is achieved with structs, interfaces and methods<->types association. Also, Go favors composition over inheritance and makes implementation of design patterns with a less bloat and same flexibility.
  2. Functions visibility - controlled by naming convention. Public functions start with capital letters when internal ones with lower case letters. The benefit of doing it this way over using scope identifiers (public, private, etc.) is that it enforces you to follow proper naming conventions.
  3. First-class functions - Go allows functions to be assigned to variables, passed as arguments to other functions and returned from other functions.
  4. Function Returning Multiple Values - in Go language, you are allowed to return multiple values from a function, using the return statement. This feature is commonly used in idiomatic Go, for example to return both result and error values from a function.
  5. Variadic functions - functions that accepts a variable number of arguments.
  6. Pointers - reminded me my struggling with them while learning C/C++ in university. C#/Java do not have pointers, however it could give you more granular control when it comes to memory management or performance fine tuning.
  7. Slices - really cool data structures that give you powerful interface to sequences. Under the hood they draw on arrays, but with much more flexibility and convenience compared to arrays.
  8. Concurrency - Go offers great support for concurrency and makes it fairly easy to implement a concurrent system with channels and waiting groups. Go supports this at the language level and implements it with lightweight threads of execution - Go routines.
  9. Documentation - every exported/public function should be commented, otherwise you'll get compilation error.

Conclusion

While comparing Go to C#, I think that Go really opts for simplicity:

  • It is a simple language, designed with minimalistic mindset.
  • The built-in library contains the most things you may need to get started with.
  • In order to keep the language simple and avoid complexity, generics are not supported.
  • The standard library is self-explanatory and consistent.
  • Consistency is enforced by the language for better readability and maintainability.

I feel like Go designers did really good job to avoid accidental complexity and built it from the ground up with the "Less is more" mindset.

Very nice. I’ll add that because of its simplicity, Go is very productive for developers. In a month or so, you can be very productive in Go.

Thanks for this post. I found it very useful.

To view or add a comment, sign in

More articles by Mark Mishaev

  • Thoughts About Event-Driven Architectures

    Introduction I was recently pondering about event-driven architectures, their benefits, downsides and most common…

  • Essential Complexity in Systems Architecture

    This week we had really unique event in Checkmarx - GeekDays, in which RnD and Product folks presented live talks in a…

    2 Comments
  • Containers Security: Clair vs. KICS

    Introduction We witness containers rapidly becoming native choice for running cloud and on-premises workloads…

  • Why Building Simple Systems is Hard?

    Going back to my previous post about achieving architectural simplicity, I'd like to ponder the question why is it so…

  • GitOps and IaC Security

    In this post, I'd like to give a brief overview of GitOps framework and how IaC security fits into GitOps concept…

  • Infrastructure Code Testing

    Introduction A lot of software design principles, such as "Keep It Simple, Stupid" (KISS), "Do-not Repeat Yourself"…

  • Decision Making in Everyday Leadership

    Many of us live in very dynamic business environments, where things happen quickly and we frequently find ourselves in…

    1 Comment
  • 10 signs to know if you're good at leading teams

    This checklist may help us to quickly assess if we're doing a good job as managers. Ask yourself these questions: Can…

    1 Comment
  • Effective One-on-One Meetings

    We can't overstate the importance of one-one-one (1-1s) meetings with our employees and team members. They are a…

    5 Comments
  • Building High-Performing Teams

    Building productive and healthy engineering teams is an art. It entails a right mix of knowledge, technical expertise…

    4 Comments

Others also viewed

Explore content categories