When it comes to choosing programming languages for your app which might be data-intensive and needs to have low computation latency, developers have to make a choice between better readability/fast development vs high-performance. Often the languages that have better readability and fast-prototyping lacks performance and it becomes main bottleneck when your app needs to serve millions of user requests.
This is the where Go comes in. Now I must tell you before moving ahead in the discussion that I have been always a Python guy due to its simplicity, fast development and better number of packages available from community and of course data!!! Python has a large number of packages available for doing ML/AI, Data Science, Data Analytics and Big Data tasks. But still it has a lot of drawbacks. Some of them according to me are:
First its an Interpreted dynamic language. Dynamic because the data mutability is allowed during the runtime which is by nature slow and can add significant latency issues.
Portability is another issue. The distribution of Python applications requires the consumer machines to have Python Interpreter installed locally.
No better way for Inter-Process Communication (IPC). The processes running in parallel needs to have a common queue or buffer in-place to allow processes share information among each other. There are middle-wares like Celery, Redis etc.
And Of course Concurrency! By default Python is not concurrent. This is due to the infamous GIL(Global Interpreter Lock) which restricts multiple threads running at the same time. There are some libraries which tries to outsmart the GIL like Asyncio, Futures etc.
And the drawback list can go on. My Job requires me to build and deploy a lot of custom applications to handle Big Data problems. Often I have to deal with Small Files Problem which is also a boon to many existing Big Data Frameworks like Apache Hadoop, Apache Spark. There are many new player in the field like Ray, Dask, Modin which allows you write thread safe concurrent and parallel application for Big Data problems.
In my belief, choosing an alternative to Python can be a great advantage when it comes to writing highly performant code. For me, Go is the first choice.
A little history about Go
Go was officially developed by Google to support its ongoing projects. Three of the Google Engineers named Robert Griesemer, Rob Pike, and Ken Thompson came up with the development plan for a programming language that can solve the issues with existing language like C++. They wanted simplicity of syntax but performance and features from languages such as C. They started developing Go September 21 2007 and after 2 years, the language was officially released as open-source project.
Today many of the projects are using Golang. Such as:
Docker
Go is popular among DevOps community, especially with Docker. It has a 90% codebase of Go. Docker is popular for application containarization and widely accepted by community, organizations etc.
Docker helps developers bring their ideas to life by conquering the complexity of app development. - Docker
github.com
Kubernetes
Kubernetes is another project that is developed using Go. It is one of the popular platform for orchestrating Docker Containers. It benefits the application by providing automated container scaling and much more.
Production-Grade Container Scheduling and Management
Kubernetes (K8s)
Kubernetes, also known as K8s, is an open source system for managing containerized applications
across multiple hosts. It provides basic mechanisms for deployment, maintenance
and scaling of applications.
Kubernetes builds upon a decade and a half of experience at Google running
production workloads at scale using a system called Borg
combined with best-of-breed ideas and practices from the community.
Kubernetes is hosted by the Cloud Native Computing Foundation (CNCF)
If your company wants to help shape the evolution of
technologies that are container-packaged, dynamically scheduled,
and microservices-oriented, consider joining the CNCF.
For details about who's involved and how Kubernetes plays a role,
read the CNCF announcement.
To start using K8s
See our documentation on kubernetes.io.
Try our interactive tutorial.
Take a free course on Scalable Microservices with Kubernetes.
To use Kubernetes code as a library in other applications, see the list…
Benefits and Drawbacks
There are a lot of benefits to Go when I try to compare it Python. Some of these are:
Statically Complied Language. Compared to Python, Go enforces type definitions to be applied to variable which are immutable during the runtime.
Code Readability is almost similar to Python so if you are transitioning from Python to Go, then the learning curve will be less steep. This also enables faster application development time and developer can be productive.
IPCs are much easier than Python and kind of native to Go. Go has Channels which allows communication between the routines running in parallel.
Of course Concurrency is main benefit of Go. Go handles concurrency by Go Routines and Channels.
Although, transitioning to Go can be a bit difficult in the beginning due to following reasons:
No OOP concepts in Go. Go is a Procedural language and sits - somewhere between Fortran, C etc. Go has Generics, Interfaces and Modules.
Go doesn’t have Exceptions and deals with bugs by producing Errors.
Go is also has a Garbage Collector similar to Python which makes it less performant than Rust, C++.
Go allows Pointers which can be dauting if you have never used these in your life.
Besides all these drawbacks, Go can be your best friend if you want to write highly performant backend systems with performance near to C and readability similar to Python. Also Go is becoming a popular language and most of the organizations are shifting to Go for their data intensive backend systems, so this means there will be a lot of demand for Go Developers in the market with Fat Paycheck.
Keeping the monetary value aside, I think you should learn Go if you are already a Python developer. It can give you an edge in terms of dealing with building high-performant systems.
Conclusion
In this article, we discussed about how Go can be your best bet when you want to write highly performant code. The language is still fresh and growing day-by-day. Community has been contributing to the project and provided some of the best frameworks and libraries.
In the next article we will discuss how to create basic programs in Go. Till then Goodbye!!