GO is a programming language with inherent asynchronous programming abilities created and open-sourced by Google. So,why do I care ? here’s why:
Programming models has evolved from sequential (or synchronous or linear) to parallel (or threaded or distributed) and then to asynchronous (or concurrent or non-blocking), each with it’s own pros and cons. Most of the enterprises use distributed/parallel programming; although it speeds up things quite a bit, it’s a nightmare to manage the thread pools and the delays induced by blocking especially if you have too many distributed micro services juggling and doing magic in the back to provide a comprehensive response which is the key motivation behind the advent of concurrent/async programming.
To understand more about these three programming models, I highly recommend to take a look at this blog post
Now that ‘why async programming?’ is taken care, let’s go to 'why GO?’ I was introduced to async programming via Python and Twisted, and it was not bad except for the callback hell, additional libraries you have to install and learn , synchronization and the global interpreter lock which keeps me from fully leveraging multiple cores on the cpu. When I started wondering about these imperfections, situations has conspired to take me to GO which I think addresses all the issues and hits he bull’s eye. It’s a compiled language and lets you use all cores, comes with inbuilt async programming abilities, easy to use channels for synchronization as well as rich standard libraries..oh ya, it has inbuilt production-ready webserver too (crazy right ?..)
So, I started doing stuff with GO and am totally enjoying it, although it takes few more brain cells than pyhton or java. Don’t take my word for it boiii, look at the numbers..
This benchmarking app I wrote has the goal of getting the details of 10 movie titles from a API of a data provider; Here’s the average time took to finish the execution in all the three programming models:
Synchronous: 998.18970995 ms Asynchronous: 191.4927846 ms
Asynchronous + Parallel (on 8 core CPU): 188.14559590000002 ms
Async is like 81% faster than Synchronous programming.
Async + ||el is like is like 3% than Async, and I am sure this will be huge depending on what you are trying to do.
Source Code can be found on my github @ https://github.com/svalleru/gobenchmark