Golang - Chapter 1
What is Go?
What is Go?
For anyone who has not heard yet,
Go is a programming language. It is actually pretty old - created by Google in 2009, but it is gaining a lot of traction within the developer community and technology-based companies for very good reasons. It is a strongly-typed, compiled language that also offers features like concurrency, memory management and garbage collection by default. And, of course, Go is free and open source.
If you are thinking, “Oh, it’s just another programming language”, then I am going to suggest vehemently that you read the pros of Go listed below.
Go has been built with concurrency in mind. Instead of threads as in other languages, Go offers coroutines which are a memory-efficient way of achieving concurrency.
If you are not familiar with concurrency, it is the ability to handle multiple tasks at the same time.
Best of Both Worlds
Go is also light-weight and optimised for performance. Programmers love C and C++ as they are compiled languages. This means that the code written is directly compiled into binaries which executes on the processor. In interpreted languages like Java, we need an intermediary to do this. Java code is converted to byte code which is interpreted by a Java Virtual Machine (JVM) which in turn compiles it into binaries.
At the same time, languages like Java offer garbage collection with JVM whereas in languages like C/C++, programmers have to handle memory themselves with things like
alloc etc. that opens up space for memory leaks.
If you come from an Object-Oriented Programming background, then you may be surprised that Go leaves out many OOP concepts like inheritance and classes. There is still some level of OOP offered such as with structs which we will see in the following chapters.
Code styles are enforced by default and checks for unused variables, methods etc. are done when compiling. This means your code will be naturally clean and maintainable.
Go is optimised for performance. Big companies like Uber have started using Go to gain high throughput of handling queries. You can easily imagine the scale at which Uber operates and the number of users and queries it handles on a per second basis. Take a look at how Uber built their highest query per second service using Go.