# Why Should You Learn Go? ![rw-book-cover](https://readwise-assets.s3.amazonaws.com/static/images/article0.00998d930354.png) URL:: https://medium.com/@kevalpatel2106/why-should-you-learn-go-f607681fad65 Author:: Keval Patel ## Highlights > From the above chart you can see that the single-thread performance and the frequency of the processor remained steady for almost a decade ([View Highlight](https://instapaper.com/read/1369930312/14869307)) > So, for the solution of above problem, > Manufacturers started adding more and more cores to the processor. Nowadays we have quad-core and octa-core CPUs available. > We also introduced hyper-threading. > Added more cache to the processor to increase the performance. ([View Highlight](https://instapaper.com/read/1369930312/14869310)) > But above solutions have its own limitations too. We cannot add more and more cache to the processor to increase performance as cache have physical limits: the bigger the cache, the slower it gets. Adding more core to the processor has its cost too. Also, that cannot scale to indefinitely. These multi-core processors can run multiple threads simultaneously and that brings concurrency to the picture. We’ll discuss it later. > So, if we cannot rely on the hardware improvements, the only way to go is more efficient software to increase the performance ([View Highlight](https://instapaper.com/read/1369930312/14869313)) > most of the modern programming languages(like Java, Python etc.) are from the ’90s single threaded environment. Most of those programming languages supports multi-threading. But the real problem comes with concurrent execution, threading-locking, race conditions and deadlocks. Those things make it hard to create a multi-threading application on those languages. > For an example, creating new thread in Java is not memory efficient. As every thread consumes approx 1MB of the memory heap size and eventually if you start spinning thousands of threads, they will put tremendous pressure on the heap and will cause shut down due to out of memory. Also, if you want to communicate between two or more threads, it’s very difficult. ([View Highlight](https://instapaper.com/read/1369930312/14869319)) > Go was released in 2009 when multi-core processors were already available. That’s why Go is built with keeping concurrency in mind. Go has goroutines instead of threads. They consume almost 2KB memory from the heap. So, you can spin millions of goroutines at any time. > How Goroutines work? Reffrance: http://golangtutorials.blogspot.in/2011/06/goroutines.html ([View Highlight](https://instapaper.com/read/1369930312/14869439)) > Goroutines have growable segmented stacks. That means they will use more memory only when needed. > Goroutines have a faster startup time than threads. > Goroutines come with built-in primitives to communicate safely between themselves (channels). > Goroutines allow you to avoid having to resort to mutex locking when sharing data structures. > Also, goroutines and OS threads do not have 1:1 mapping. A single goroutine can run on multiple threads. Goroutines are multiplexed into small number of OS threads. ([View Highlight](https://instapaper.com/read/1369930312/14869441)) > Go runs directly on underlying hardware. > One most considerable benefit of using C, C++ over other modern higher level languages like Java/Python is their performance. Because C/C++ are compiled and not interpreted. > Processors understand binaries. Generally, when you build an application using Java or other JVM-based languages when you compile your project, it compiles the human readable code to byte-code which can be understood by JVM or other virtual machines that run on top of underlying OS. While execution, VM interprets those bytecodes and convert them to the binaries that processors can understand. ([View Highlight](https://instapaper.com/read/1369930312/14869448)) > C/C++ does not execute on VMs and that removes one step from the execution cycle and increases the performance. It directly compiles the human readable code to binaries. ([View Highlight](https://instapaper.com/read/1369930312/14869454)) > Like lower level languages like C/C++, Go is compiled language. That means performance is almost nearer to lower level languages. It also uses garbage collection to allocation and removal of the object. So, no more malloc() and free() statements!!! Cool!!! ([View Highlight](https://instapaper.com/read/1369930312/14869457)) > Code written in Go is easy to maintain. ([View Highlight](https://instapaper.com/read/1369930312/14869461)) > No classes. Every thing is divided into packages only. Go has only structs instead of classes. > Does not support inheritance. That will make code easy to modify. In other languages like Java/Python, if the class ABC inherits class XYZ and you make some changes in class XYZ, then that may produce some side effects in other classes that inherit XYZ. By removing inheritance, Go makes it easy to understand the code also (as there is no super class to look at while looking at a piece of code). > No constructors. > No annotations. > No generics. > No exceptions. ([View Highlight](https://instapaper.com/read/1369930312/14869464)) > Go is designed by Google to solve their problems of supporting scalability and effectiveness. Those are the same issues you will face while creating your own servers. ([View Highlight](https://instapaper.com/read/1369930312/14869487)) --- Title: Why Should You Learn Go? Author: Keval Patel Tags: readwise, articles date: 2024-01-30 --- # Why Should You Learn Go? ![rw-book-cover](https://readwise-assets.s3.amazonaws.com/static/images/article0.00998d930354.png) URL:: https://medium.com/@kevalpatel2106/why-should-you-learn-go-f607681fad65 Author:: Keval Patel ## AI-Generated Summary None ## Highlights > From the above chart you can see that the single-thread performance and the frequency of the processor remained steady for almost a decade ([View Highlight](https://instapaper.com/read/1369930312/14869307)) > So, for the solution of above problem, > Manufacturers started adding more and more cores to the processor. Nowadays we have quad-core and octa-core CPUs available. > We also introduced hyper-threading. > Added more cache to the processor to increase the performance. ([View Highlight](https://instapaper.com/read/1369930312/14869310)) > But above solutions have its own limitations too. We cannot add more and more cache to the processor to increase performance as cache have physical limits: the bigger the cache, the slower it gets. Adding more core to the processor has its cost too. Also, that cannot scale to indefinitely. These multi-core processors can run multiple threads simultaneously and that brings concurrency to the picture. We’ll discuss it later. > So, if we cannot rely on the hardware improvements, the only way to go is more efficient software to increase the performance ([View Highlight](https://instapaper.com/read/1369930312/14869313)) > most of the modern programming languages(like Java, Python etc.) are from the ’90s single threaded environment. Most of those programming languages supports multi-threading. But the real problem comes with concurrent execution, threading-locking, race conditions and deadlocks. Those things make it hard to create a multi-threading application on those languages. > For an example, creating new thread in Java is not memory efficient. As every thread consumes approx 1MB of the memory heap size and eventually if you start spinning thousands of threads, they will put tremendous pressure on the heap and will cause shut down due to out of memory. Also, if you want to communicate between two or more threads, it’s very difficult. ([View Highlight](https://instapaper.com/read/1369930312/14869319)) > Go was released in 2009 when multi-core processors were already available. That’s why Go is built with keeping concurrency in mind. Go has goroutines instead of threads. They consume almost 2KB memory from the heap. So, you can spin millions of goroutines at any time. > How Goroutines work? Reffrance: http://golangtutorials.blogspot.in/2011/06/goroutines.html ([View Highlight](https://instapaper.com/read/1369930312/14869439)) > Goroutines have growable segmented stacks. That means they will use more memory only when needed. > Goroutines have a faster startup time than threads. > Goroutines come with built-in primitives to communicate safely between themselves (channels). > Goroutines allow you to avoid having to resort to mutex locking when sharing data structures. > Also, goroutines and OS threads do not have 1:1 mapping. A single goroutine can run on multiple threads. Goroutines are multiplexed into small number of OS threads. ([View Highlight](https://instapaper.com/read/1369930312/14869441)) > Go runs directly on underlying hardware. > One most considerable benefit of using C, C++ over other modern higher level languages like Java/Python is their performance. Because C/C++ are compiled and not interpreted. > Processors understand binaries. Generally, when you build an application using Java or other JVM-based languages when you compile your project, it compiles the human readable code to byte-code which can be understood by JVM or other virtual machines that run on top of underlying OS. While execution, VM interprets those bytecodes and convert them to the binaries that processors can understand. ([View Highlight](https://instapaper.com/read/1369930312/14869448)) > C/C++ does not execute on VMs and that removes one step from the execution cycle and increases the performance. It directly compiles the human readable code to binaries. ([View Highlight](https://instapaper.com/read/1369930312/14869454)) > Like lower level languages like C/C++, Go is compiled language. That means performance is almost nearer to lower level languages. It also uses garbage collection to allocation and removal of the object. So, no more malloc() and free() statements!!! Cool!!! ([View Highlight](https://instapaper.com/read/1369930312/14869457)) > Code written in Go is easy to maintain. ([View Highlight](https://instapaper.com/read/1369930312/14869461)) > No classes. Every thing is divided into packages only. Go has only structs instead of classes. > Does not support inheritance. That will make code easy to modify. In other languages like Java/Python, if the class ABC inherits class XYZ and you make some changes in class XYZ, then that may produce some side effects in other classes that inherit XYZ. By removing inheritance, Go makes it easy to understand the code also (as there is no super class to look at while looking at a piece of code). > No constructors. > No annotations. > No generics. > No exceptions. ([View Highlight](https://instapaper.com/read/1369930312/14869464)) > Go is designed by Google to solve their problems of supporting scalability and effectiveness. Those are the same issues you will face while creating your own servers. ([View Highlight](https://instapaper.com/read/1369930312/14869487))