Home > Article > Backend Development > Why is golang so popular?
Why is golang so popular?
The reasons why golang is so popular:
1, Concurrency’s native support
through the language’s native Goroutine and Channel, which support Concurrency very well. You can think of Goroutine as a very lightweight Thread.
A Goroutine only occupies 2KB of memory, but a Thread occupies 1MB of memory.
The overhead of Goroutine creation, destruction and switching is particularly low compared to threads. You can start thousands of Goroutines at any time, which will make your coding extremely simple.
Go runtime handles all operations related to Goroutine. In fact, Goroutine also runs on the Thread of the operating system.
2, Go's dependency management
For C/C and Java, dependency management is a problem that drives most novices crazy. You need to write CMakeLists.txt/Makefile or configure Maven.
Go's dependency management is very simple:
Define a root directory $GOROOT to save all your code.
Your code and dependencies are placed under a fixed relative path according to Go's convention. The go get command can help you download all dependent packages.
Go also has some dependency management tools, I currently use glide.
3, Static linking
Friends who deploy C/C services must be familiar with the concepts of static linking and dynamic linking. When deploying the server, the management of the dynamic link library is also a very troublesome thing. It can often be run locally, but not on another server. The emergence of Docker has simplified this problem to a certain extent.
Go is compiled using static linking by default, so it is particularly convenient during deployment. You only need to copy a single binary file.
4, Go's tool chain
The tool chain officially supported by Go is very complete and easy to use. Commonly used tools include testing, benchmark, performance tuning, etc. In a mature development process, coding only takes up a small amount of time, and more time is spent on testing and tuning, so a useful tool chain is important to improve efficiency.
5, Go’s community
Go is backed by Google and has a very healthy and active open source community. The official package itself is very powerful, and the community has also contributed a lot of useful components. In addition, there are many Go documents and excellent blogs, and the learning cost is low.
In background development, except for some specific scenarios that require the use of C/C, such as CUDA, CPU-intensive or IO-intensive, you can try to use Go for everything else.
Recommended tutorial: "Go Language Tutorial"
The above is the detailed content of Why is golang so popular?. For more information, please follow other related articles on the PHP Chinese website!