Golang
Language introduction
Summary
Golang(also known as Go) is a statically strongly typed, compiled, combined, and garbage-collection programming language developed by Google.
Robert Grisemo, Rob Pike, and Ken Thompson began designing GO in September 2007, with Ian Lance Taylor and Russ Cox joining the project. Go is based on the Inferno operating system. Go was officially announced in November 2009 as an open source project, supporting Linux, macOS, Windows and other operating systems. In 2016, Go was selected as "TIOBE's Best Language of 2016" by software review company TIOBE.
Currently, Go releases a secondary version (i.e. upgrade from a.x to a.y) every six months.
Description
Go's syntax is similar to C's, but the declaration of variables is different. Go supports garbage collection. Go's parallel computing model is based on Tony Hall's Communication Sequential Process (CSP). Other languages that adopt a similar model include Occam and Limbo[3], and Go also has features of this model, such as channel transport. Parallel constructs such as goroutine and channels can be used to build thread pools and pipelines [8]. Plugin support was opened in 1.8, which means that some functions can now be dynamically loaded from Go.
In contrast to C++, Go does not include features such as enumeration, exception handling, inheritance, generics, assertions, virtual functions, etc., but adds language-level support for features such as Slice, concurrency, pipelines, garbage collection, interfaces, etc. Go 2.0 will support generics [9], taking a negative view of the existence of assertions, while also defending itself against providing type inheritance.
Unlike Java, Go natively provides associative arrays (also known as Hashes or Dictionaries), just like string types.
History
In 2007, Google designed Go to improve development efficiency in multi-core, networked machines, and large codebases. At Google, designers wanted to address the drawbacks of using other languages, but still retain their advantages.
Static typing and runtime efficiency. (e.g. C++) Readability and ease of use. (e.g. Python and JavaScript) [12] High performance network and multi-process. The designers were largely inspired by the "Don't be like C++" mantra circulating among themselves.
Go was officially announced in November 2009, [16] and version 1.0 was released in March 2012. Since then, Go has been widely used in Google products and many other organizations and open source projects.
In November 2016, Go (a sans-serif body) and Go Mono (an equal width font) were released by designers Charles Bigelow and Kris Holmes, respectively. Both fonts use WGL4 and use large x-height and letterforms clearly according to DIN 1450.
In August 2018, the local icon was changed. However, the Gopher mascot still bears the same name.
In August 2018, Go's major contributors released two "draft designs" for new features of the language - generics and exception handling - while seeking feedback from Go users. Go was criticized for its lack of generic programming support and lengthy exception handling at 1.x.
The above is from the wiki, more details can be found
Why do I need to learn Golang?
"Go will be the server language of the future." - Tobias Lutke, Shopify Hardware limitations Moore's Law is failing.
Intel introduced the first Pentium 4 processor with a 3.0 GHz clock speed in 2004. Today, my 2016 MacBook Pro has a clock speed of 2.9 GHz. As a result, there has not been much increase in raw processing capacity for almost a decade. You can see the increase in processing power relative to time in the graph below.
As you can see from the chart above, single-threaded performance and processor frequency have remained almost constant for the last decade. If you think adding more transistors is a solution to the problem, you're wrong. This is because at the microscopic scale, quantum properties begin to appear (e.g., quantum tunneling), and the more transistors you put in, the more expensive it becomes (why?). Moreover, the number of transistors that could be added per dollar also began to decline.
Therefore, the solutions to the above problems are as follows:
Vendors started adding more and more cores to processors. Today, we have four - and eight-core cpus available. We also introduced hyperthreading technology. Add more cache to the processor to improve performance. However, these options have their own limitations. We can't add more caches to the processor to improve performance because caches have physical limitations: the bigger the cache, the slower it is. Adding more cores to the processor also has its costs. Moreover, this cannot be extended indefinitely. These multi-core processors can run multiple threads at the same time, but also bring concurrency capabilities. We'll talk about that later.
So if we can't rely on hardware improvements, the only way out is to find an efficient software to improve performance, but unfortunately, modern programming languages aren't that efficient.
"Modern processors are like a drag racing car with nitrogen and oxygen acceleration systems, and they perform well in drag racing. Unfortunately, modern programming languages are like the Monte Carlo circuit, they have a lot of corners." - David Ungar
Go inherently supports concurrency
As mentioned above, hardware providers are adding more cores to processors to improve performance. All data centers are running on these processors, and we should expect the number of cores to grow in the coming years. More importantly, today's applications use multiple microservices to maintain database connections, message queues, and cache maintenance. Therefore, the software and programming languages we develop can support concurrency more easily, and they should be scalable as the number of cores grows.
But most modern programming languages (like Java, Python, etc.) come from the single-threaded environment of the 90's. Most of these languages support multithreading. But the real problem is concurrent execution, thread locks, race conditions, and deadlocks. These issues make it difficult to create a multithreaded application in these languages.
For example, creating new threads in Java consumes a lot of memory. Because each thread consumes about 1 MB of heap memory, if you run thousands of threads, they will put a huge strain on the heap and eventually crash due to insufficient memory. In addition, if you want to communicate between two or more threads, it is very difficult.
Go, on the other hand, was released in 2009, by which time multicore processors were already on the market. That's why Go is built with concurrency in mind. Instead of threads, Go uses goroutine, which consumes about 2 KB of memory from the heap. So you can launch millions of Goroutines at any time.
Go runs directly on the underlying hardware
The biggest advantage of using C++ compared to other modern high-level languages such as Java/Python is its performance, because C/C++ is a compiled language rather than an interpreted language.
The processor understands binary files. Typically, when you compile an application built in Java or another JVM-based language, it compiles human-readable code into byte code, which can be understood by the JVM or other virtual machines running on top of the underlying operating system. When executed, the virtual machine interprets these bytecodes and converts them into binary files that the processor can understand.
Code written in Go is easy to maintain
I'll tell you one thing, Go doesn't go crazy with programming syntax like other languages, its syntax is pretty neat.
The designers of Go had this in mind when Google created the language, and since Google has a very powerful codebase, with thousands of developers all working on the same codebase, the code should be easy for other developers to understand, and one piece of code should have minimal impact on another. All of this makes the code easy to maintain and easy to modify.
Go deliberately ignores the features of many modern object-oriented languages.
There is no class. All code is separated by package only, and Go has only structs instead of classes. Inheritance is not supported. This will make the code easy to modify. In other languages, such as Java/Python, if class ABC inherits class XYZ and you make some changes in class XYZ, then this may cause some side effects in other classes that inherit class XYZ. By removing inheritance, Go also makes it easy to understand the code (because you don't need to look at the parent class when you look at a piece of code). There is no constructor. There are no comments. There are no generics. Nothing abnormal. These changes make Go very different from other languages, which makes programming in Go very different from other languages. You may not like some of the ideas above. However, that's not to say that you can't code your application without these features. All you have to do is write a few more lines of code, but on the positive side, it will make your code clearer and add more clarity to the code.
Go is coming with a vengeance
I know it's not a direct technical advantage, but Go was designed and powered by Google, which has one of the largest cloud infrastructures in the world, and it's massive. Google designed Go to address scalability and effectiveness issues. These are the problems we all face when creating our own servers. Go is also used by large companies such as Adobe, BBC, IBM, Intel and even Medium.