Why use the Go language? What are the advantages of the Go language?

Source: Internet
Author: User

What are the more successful software developed using the Go language?
Which companies are using Go in China, do you have any guidance? 8 Reviews Sharedefault sort sorted by Time49 Answers514 agreed objection, will not show your nameRiopython topic excellent respondents vc/podcast presenter/former engineer included in editorial recommendation ? 514 people agree Most of the projects are written in Python, and a few small items are written in Go. I'm talking about the pros of go from a Python-based developer's perspective:
  1. Simple deployment. Go compilation generates a static executable file with no external dependencies other than glibc. This makes deployment incredibly convenient: only a basic system and the necessary management and monitoring tools are needed on the target machine, so it is not necessary to worry about the dependencies of the various packages and libraries required by the application, which greatly reduces the burden of maintenance. This is a huge difference from Python. For historical reasons, Python's deployment tools are ecologically quite chaotic "such as Setuptools, Distutils, Pip, Buildout's different applications and compatibility issues." The official PyPI source is often problematic and requires a private image, while maintaining the image takes a lot of time and effort.
  2. Concurrency is good. Goroutine and channel make it easy to write high-concurrency server-side software, and in many cases there is no need to consider locking mechanisms and the various problems that arise. A single Go application can also effectively utilize multiple CPU cores and perform well in parallel. This is also the Tianrang of Python. Multi-threaded and multi-process server-side programs are not easy to write, and because of the global lock GIL, multi-threaded Python program is not efficient use of multicore, can only be deployed in a multi-process way, if the multiprocessing package in the standard library will be a lot of monitoring and management challenges " We use the Supervisor management process, the fork support is not good ". When you deploy a python application, you typically deploy an application for each CPU core, which can cause a lot of wasted resources, such as assuming that a Python application takes up 100MB of memory while the server has 32 CPU cores, leaving a kernel to the system and running 31 copies of the application will waste 3 GB of memory resources.
  3. Good language design. From the academic point of view the go language is very mediocre, does not support many advanced language features, but from the engineering point of view, go design is very good: The specification is simple enough and flexible, the other language based programmers can quickly get started. More importantly, Go comes with a complete tool chain, which greatly improves the consistency of team collaboration. For example, GOFMT Auto-typesetting Go code, to a large extent, to eliminate the different people write code layout style inconsistent. The editor is configured to automatically run GOFMT when editing the archive, so that you can place the position when you write the code, and automatically turn it into the correct code when you archive it. There are also very useful tools such as Gofix, Govet and so on.
  4. Good execution performance. It's not as good as C and Java, but it's usually a bit higher than the native Python app, and it's suitable for writing some bottleneck business. The memory footprint is also very provincial.
Edited on 2013-08-01 66 reviews thanks for sharing collection? No help ? application for reprint 192 agreed objection, will not show your nameyou know , I'm the guy from the south. 192 people agree background

Prior to contacting Golang, I used C + +, LUA and Python as the main development language.

Problems with C + +:

    • Low development efficiency, high demand for developers
    • LIBC only backwards compatible, the operation of the difficulty is too large

Lua/python's question:

    • Dynamic language, lack of compilation process, low-level error frequency
    • Lack of effective performance analysis and debugging tools
Scene

Just completed the development of Nginx WAF module, began to set up a WAF management system. As the fluentd used by colleagues as a log collection component, I chose fluentd to maintain the consistency of the underlying components. That is, the final architecture is fluentd->mongodb->mysql, and then the front-end data display based on MySQL. After being dug up many times, I decided to rewrite fluentd with go to solve the following problems:

    • Fluentd in Ubuntu 9.04 occasionally appears suspended animation, resulting in data loss
    • Fluentd difficult to access the company's existing package release system, resulting in a very difficult operation
    • MongoDB is implemented with MMAP, which consumes too much memory when the data volume is large
Programme
    • Please click here for the Gofluent code.
    • Please click here for the HTTPMQ code.

In fact, all two of these projects are designed to address the above mentioned issues. Perhaps you do not believe, these two sets of code is I finished in my spare time, that is, it is not counted within the KPI. Actually at the beginning I did not expect to be able to write so quickly 7788, after all, is now learning to use AH. But the reality is, I spent a week writing HTTPMQ, one months more time to write the gofluent ... Of course, there are a lot of imperfections in these two projects. For the current log collection scenario, I would recommend Elastic/logstash-forwarder GitHub and Elastic/logstash Use with GitHub.


Why Choose Golang

So, why would I choose Golang? In fact, I've spent a lot of time doing detailed research before making this choice. Foreign such as Google, AWS, Cloudflare, CoreOS, etc., domestic such as seven cattle, Ali, etc. have begun to use Golang to develop their cloud computing related products. Follow the footsteps of world-class giants should not go in the wrong direction, and in the process of learning Golang, I have gradually been the design philosophy behind it.


In addition, the Cloud wind blog has said such a sentence:

I found that it took me four years to temper my ability to build a system in C language, trying to find a specification that could better write software. It turned out to be just a parody of Go. The lack of language support can only be a parody.

Here is my superficial understanding of Golang:

    • With C Foundation, learning Golang is very easy
    • Synchronous mode for high concurrency with ease
    • Simple code, uniform format, easy to read
    • Strong performance, and development efficiency is not worse than Python and other dynamic languages
effect

The first ready to go online when in fact the mind quite disturbed, after all, if there is a failure, not only the bag to his back, face also on the wrong AH. Fortunately the result is pretty, since the launch did not appear a sudden bug, reduce the difficulty of operation and reduce the load of the machine.


All in all, from an engineering standpoint, choosing Golang is a very smart choice for most background applications. This makes it easy to take into account the operational performance, development efficiency and maintenance difficulty of the three great many programs ape desire to die of singularity.

Why use the Go language? What are the advantages of the Go language?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.