Golang- What and Why
Meet Rajesh Gor
Posted on April 1, 2022
Introduction
This is the first entry in my 100 days of Go lang challenge. I will share the things I will learn each day for 100 days related to Golang or its configuration in my environment. In this post, we will understand what is golang and why you should learn it. It's not an in-depth guide but a high-level overview for understanding the context of learning Go lang.
A bit of Context
In April 2021, I started learning Django and to date, I have more than 10 projects(not all deployed) created and publicly open on GitHub. It has been a great experience so far, I am still in between an internship with a project to be created in Django. The learning process after I started blogging in June 2021 has been a different fantasy, I have been enjoying the process of writing the things I learn. So, this Spring/Summer I am creating a challenge of 100 days for learning Go lang and documenting the process. Hopefully, this will be a useful place to learn for a beginner and more than that a place for me to reflect back on the future.
Leaving the rant aside, let's start with the best question to answer, What is Golang?
What is Golang
Golang (officially called Go) is a programming language developed by people working at Google. It is statically typed like C\C++, Java, Kotlin, etc, and syntax is similar to dynamically languages like Python, Js, Ruby, Lua, etc. So, golang provides the best of both worlds, the swiftness to write code and also providing control and memory safety. Go is regarded as the language of the cloud i.e. it is heavily used in the cloud infrastructure, it involves creating microservices, APIs, containerization, orchestration, and a lot of other technologies. It can be a super useful programming language for DevOps folks and people into Cloud computing.
Though Go is designed for Cloud Infrastructure, that doesn't mean you can't use it elsewhere. There are a lot of fields in which golang nicely fits. We'll discuss why you would want to learn golang and state the domains where it can be used.
Go programmers are called Gophers
Why learn Golang?
There are a lot of reasons for learning Go as your next programming language. Not only it is quite famous but it is significantly faster than other programming languages like python and javascript. It is a simple language to pick up, it is designed for modern world technologies. There is an added advantage to learning go lang as it is a new programming language(not as old as python). It was open-sourced in 2012, it got a great boost in the last five years as cloud companies are on the rise.
1. GO lang is simple
GO lang is a simple programming language, it is really easy to learn. It is quite similar to python in terms of its syntax, though it also inherits characteristics from the Java/C++ paradigm. It has a single entry point program via the main
function similar to Java/C++ languages and is compiled into binary/executable code before running. It has the standard library that provides a lot of functionalities out of the box. It provides some quite handy tools and has support for creating web applications in the core language itself.
2. GO lang is fast (Execution Speed)
Though it might not be the fastest language of all time, it beats python and javascript by a significant magnitude in the context of backend development. Go lang is compiled language and hence it has no overhead of converting into byte code or the interpreter. Go lang also checks for unused variables, functions, identifiers, and packages, this can boost the speed of execution by a good amount additionally optimizing the memory footprint of the program.
We can see, that Go lang is almost equivalent to C and C++ porgramming language, though this might not be the best comparison of speed as it depends on quite a lot of factors and the context of programs. Still Go lang has a significant edge over Java and C++ which is a great factor because of the writing complexity involved in those programming languages.
3. GO lang is fast (Writing Speed)
GO language is fast yes I get that, It is faster in terms of writing speed. If you sit down to write the same code in Java/C++ or Go, having time constraints, you will move out with Go as a winner. It is much easier to write code in Go than compared to C/C++, Java, or even Javascript. Golang prefers clear code over fast code, though it might not be as fastest as Rust or C++, it is definitely much easier and quicker to write than the other counterparts. Go is designed for writing software that can scale with large codebases and teams. So it's not a surprise it is used to create cloud computing technologies like Docker, Kubernetes, and other tons of cloud-native tools.
4. GO lang is made for the modern world
Go lang is the modern C
Go lang is a modern language, it is not as ancient as C/C++ or Java. It is designed for Cloud-native applications which are scalable and optimized for performance meeting the needs of the modern demand for bleeding-edge technologies. It is designed by the people who created the UNIX operation, Ken Thompson. Though there were other go authors like Robert Griesemer and Rob Pike. Go lang has been designed keeping the idea of C but also considering the context of the modern world. It makes tasks like concurrency a lot simpler but it avoids dangerous and manual control of memory by not allowing pointer arithmetic.
Where you can use Golang
Go land finds its use case in a lot of domains including Cloud computing, Web applications, CLI and DevOps tools, and so on. As GO is a general-purpose programming language, you can use it anywhere in the relevant fields of technology.
Cloud-native application
As Golang has capabilities to execute low-level system calls efficiently, cloud-native tools can be created in golang for improving efficiency and memory usage. As Go uses fewer resources like CPU and memory, it can optimally be used for applications that require almost no delay in the response. It also handles concurrency very well using goroutines which are way simpler to implement. All the factors contribute very well to constructing a modern cloud-native application.
Golang is used in Cloud-native technologies like
- Docker - containerisation technology
- Kubernetes - Container Orchestration
- Google Cloud - Cloud Hosting Plaform
This makes Golang widely adopted and has firm grounds for the future as well.
Web applications
As Golang is highly efficient and fast it can be used to develop web applications. It can scale a web application very well as it is a statically typed ecosystem. It also has extensive support for integrating databases into web applications. Golang doesn't require any 3rd party integrations to create the web apps, it is developed using internal or external packages and modules. The performance of Golang is the core feature for creating web apps in it, it heavily outperforms Javascript(Node) and Python. As golang code is compiled before running, this makes a single executable depending on the operating system, this improves the performance to a great extent. So, golang should be an ideal choice for developing web applications.
- Soundcloud - Music System Webapp
- Uber - Cab Booking/Ride Sharing App
- Allergo - E-commerce Webappp
DevOps tools
A lot of DevOps tools like Prometheus, Grafana, Terraform, Hugo are written natively in Go. Having appropriate features like simplicity, scalability, efficiency, and concurrency, go lang fits the DevOps space really well. Golang is already used in cloud-native technologies as mentioned earlier adopting it in the DevOps space is a great choice as it creates an even and supportive ecosystem. The Write once and Run anywhere
paradigm of java is surprisingly built-in golang as well without conversion into byte code. This is a great feature any DevOps engineer would dream of, using a single code base for multiple platforms can save a lot of time and improve productivity.
- Prometheus - Monitoring system and time series database
- Grafana - Platform for monitoring and observability
- Terraform - Building, Changing, and Versioning Infrastructure
- Minikube - Run kubernetes locally
- Kit- standard library for microservices
Who uses Golang?
Golang is a widely used programmming language, it is used by some of the big companies around the world. Of course Google uses it, apart from Google, it is being used by companies like:
- Netflix
- PayPal
- Microsoft
- Dropbox
- Meta (facebook)
- Uber
- Twitch
There are so many tools created tools using golang like the gh-cli, cockrach-db, jwt, etc. You can see a whole list of applications/tools/frameworks written in Go from this awesome list
Conclusion
Go lang is a excellent choice for any one into web developement, cloud native, DevOps, CLI tools. Go lang being a recently developed language it has grown a lot faster than any other language in the programming world. Learning Python over the span of two years, I might want to dabble into Go but not completely leave Python. Python has a great community and is widely adopted in almost all fields in developement. Still trying out new things is what keeps you in the hunt of oppurtunitiees and meeting new people.
So starting from today, I will share my learning a new thing in Go lang every day for 100 days. At least that's the plan. The post might be in the form of a long post or a short TIL on the blog. Check out the GitHub repository for the 100 day challenge here. If you have any queries, suggestions, or feedback please let me know in the comments or on the mentioned social handles. Thank you for reading. Happy Coding :)
Posted on April 1, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.