I started learning Golang
Estimated reading time: 4 minutes
You may be wondering what motivated me, as a JavaScript developer, to invest my time in learning a new programming language. The truth is that the idea hit me recently after reading “Pragmatic Programmer” by David Thomas and Andrew Hunt. You can argue if this book is outdated or not but I particularly liked one piece of advice - you should learn one programming language every year. Learning a new language can be a daunting task, but it can also be a valuable opportunity to expand your skill set and gain a new perspective on programming. In my case, I was drawn to Golang’s simplicity, speed, and concurrency capabilities, as well as its growing popularity in the industry.
Golang was designed to solve some of the common problems that arise in modern software development. One of the biggest problems that Golang solves is the issue of concurrency. In today’s world, applications need to handle multiple tasks simultaneously, and traditional languages like C++ and Java can be cumbersome when it comes to dealing with concurrent operations. Golang provides powerful and efficient concurrency features, including goroutines and channels, which allow developers to handle multiple tasks at the same time with ease. Another problem that Golang solves is the challenge of managing large codebases. Golang has a strong focus on simplicity and readability, making it easier to write and maintain code over time. It also includes a garbage collector that automatically frees up memory, reducing the risk of memory leaks and other performance issues. Additionally, Golang was designed to be fast and efficient, making it a great choice for applications that require high performance and scalability. Overall, Golang is a language that addresses many of the pain points that developers face in modern software development, making it an attractive choice for many projects.
I must admit that my first contact with the new programming language was very intriguing. There are many differences between both languages. Golang has a different syntax and is strongly typed. It means that you need to declare the data type of a variable before using it. It is also worth mentioning that you can’t compile a Golang program if there are unused variables in your code. All of this makes Golang code easier to read and understand, but it can also require more typing and be less flexible than JavaScript. In the end, being less flexible is good in my opinion - because of that you make fewer mistakes during development and the code you produce is “bug-proof”. Another key difference is how Golang handles concurrency, which is one of its standout features. In Golang, concurrency is built into the language itself through goroutines and channels, which allow for easy and efficient communication between processes. This can make it easier to write highly concurrent applications, but can also require a different way of thinking compared to JavaScript’s event loop and asynchronous programming model. Overall, while there are certainly similarities between Golang and JavaScript, there are also significant differences that you’ll need to understand and adapt.
One of the biggest challenges of learning a new programming language is figuring out what to build with it. It can be easy to get bogged down in tutorials and theory without actually applying your knowledge to real-world projects. As someone who has recently started learning Golang, I found myself struggling to come up with project ideas. One time I was reading “Senior Engineer Mindset” by Swizec Teller. The author mentioned in one of the chapters that he loves the Advent of Code (https://adventofcode.com/). It is an annual event where participants solve a new programming challenge each day leading up to Christmas. The puzzles are designed to be challenging but fun, and they allow you to learn and test a broad set of skills in the language of your choice. Of course, Christmas time is already past us but it doesn’t matter. Tasks are available all the time and you can come back to them at any time. You should definitely try them out if you haven’t done that already! I started to solve the tasks and so far love them. Frankly speaking, I haven’t had such fun in quite some time.
All my Advent of Code solutions written in Golang can be found here 👉 https://github.com/sSwiergosz/advent-of-code-2022
Learning Golang as a JavaScript developer can be a challenging but rewarding experience (at least that’s what I hope for!). Whether you’re learning Golang or another programming language, the key is to remain curious, persistent, and committed to learning. With time and practice, you’ll develop the skills and knowledge needed to build amazing software using Golang.
Links & references
- Advent of Code (https://adventofcode.com/)
- Pragmatic Programmer book (https://en.wikipedia.org/wiki/The_Pragmatic_Programmer)
- Senior Engineer Mindset (https://swizec.com/senior-mindset/)
- Golang docs (https://go.dev/doc/)