GoLang! The next generation programming language.
For me, GoLang is like “Saitama” of languages. It has got almost every feature which is intentionally designed to beat all the conventional programming languages in almost all the departments. Be it efficient utilisation of processors, being platform independent, its speed in terms of compilation and performance, lesser code for same functionalities etc.
Developed and maintained by Google itself, Go language or alternatively Golang is one of the fastest growing programming languages in the software industry. Its speed, simplicity, and reliability make it the perfect choice for all kinds of developers.
In past couple of years, popularity of Golang increased tremendously. My goal here is not to teach you, how you can write “Hello World!!” in this article, as you can do it better by yourself.
I am here to explain why and where we need new language like Go?
1)WHY GOLANG IS SO POPULAR ?
- Go offers a native concurrency model. Go relies on a concurrency model called CSP ( Communicating Sequential Processes).
- Tons of free official guides, open-source, huge collection of add-ons and packages.
- Go is cross-platform, so you can target an operating system of your choice when compiling a piece of code.
- Go has a fairly mature package of its own. Once you install Go, you can build production level software that can cover a wide range of use cases from Restful web APIs to encryption software, before needing to consider any third party packages.
- Go code typically compiles to a single native binary, which basically makes deploying an application written in Go as easy as copying the application file to the destination server.
- Go is also being rapidly being adopted as the go-to cloud native language and by leading projects like Docker and Ethereum. It’s concurrency feature and easy deployment make it a popular choice for cloud development.
- Fastest growing language(more than 1.5 times), amongst C/C++, JAVA & Python.
2) OPEN SOURCE & BACKED BY BIG ORGANISATIONS :
The language was developed at Google. Initially it was a project lead by Rob Pike, Robert Griesemer, and Ken Thompson which was later released as an open-source project in 2009. Currently it is having more than 90,000 repositories. Since August 2015, numerous releases were made with lot of improvements. Go can be used for development of different kinds of software starting with cloud and systems programming and extending to game server development and handling text-processing problems.
Here is the list of popular companies using it:
- Dropbox
- Soundcloud
- Docker
- Cloudflare
- BBC
- Uber
- Medium
And the list is continuously increasing :D .
3) GOROUTINES (SOME SERIOUS PARALLELISM :D )
Most of the modern programming languages(like Java, Python etc.) are single threaded environment and they also support Multithreading. But there are problems like concurrent execution, threading-locking, race conditions and deadlocks which are tough challenges in making or having Multi-Threaded application.
Golang uses goroutines instead of threads, each having a consumption of 2KB memory from the heap, which can be executed parallelly in millions. Other key points are as follows :
- Have dynamic segmented stacks which can use more memory on demand.
- Have faster startup time than threads.
- Have built-in method to communicate between channels.
- It allows you to avoid having to resort to mutex locking when sharing data structures.
- A single goroutine can run on multiple OS threads and are multiplexed into small number of OS threads. In simple terms it allows you to communicate the value stored in your variable from one thread to another.
4) NO NEED FOR WEB FRAMEWORKS
This is the part I loved the most. Golang community have incorporated many tools natively supported by language core. For example it has http, json, html templating built in language natively and you can build very complex API services without any library.
Although, there are many frameworks which are available in the community, but trust me, you will find it way easier to write the API’s without using any framework.
5) BRINGS BEST OF OBJECT ORIENTED LANGUAGES LIKE JAVA, C/C++ & PYTHON
Go provides you high performance like C/C++, super efficient concurrency handling like Java and fun to code like Python/Perl.
Like lower level languages like C/C++, Go is compiled language. It is compiled to machine code and is executed directly. It also uses garbage collection to allocation and removal of the object. So, no more malloc() and free() statements.
Golang is objet oriented but intentionally leaves out many features of modern OOP languages:
- No classes. Every thing is divided into packages only. It 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, GoLang 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.
6) CROSS PLATFORM SUPPORT
Golang was created to be usable across multiple platforms. It has plenty of built-in language features that enable easy cross-platform development. Unlike Java is does not uses any VM’s and directly compiles on the machine level which provides it the capability of being a platform independent language like C/C++.
Therefore capable to run on any metal :D
Summary
Considering the above pointers it appears to me that Golang is a perfect choice for web development and micro services. Its not limited to platforms, succeeds in writing APIs and supports JSON format pretty well. It is easier to write and also gives tons of built in functionalities where user never needs and extra library. It’s community is continuously growing day by day and is also backed by Google, so one can see it long lasting like other conventional languages.