Why use the Go language, where is the go language advantage?

Source: Internet
Author: User
Tags couchbase apcera
This is a creation in Article, where the information may have evolved or changed. 1. What is the advantage of Go
  • Can be directly compiled into machine code, do not rely on other libraries, glibc version has certain requirements, deployment is to throw a file up to complete.
  • Static type language, but there is the feeling of dynamic language, static type of language is can be compiled at the time to check out the most hidden problems, dynamic language feeling is that there are a lot of packages can be used, writing up the efficiency is very high.
  • Language level support concurrency, this is go the biggest feature, innate support concurrency, I once said a word, innate gene and plastic surgery is a difference, everyone is as beautiful, but you like plastic surgery or natural genetic beauty? Go is a gene that supports concurrency, makes full use of multicore, and is easy to use concurrently.
  • Built-in runtime, which supports garbage collection, is one of the features of dynamic languages, although the GC is not perfect at the moment, but it is sufficient to cope with most of the situations we can encounter, especially after Go1.1.
  • Easy to learn, go language authors have a C gene, then go naturally has a C gene, then the GO keyword is 25, but the ability to express is very powerful, almost support most of the features you have seen in other languages: inheritance, overloading, objects and so on.
  • Rich standard library, go now has built up a large number of libraries, especially the network library is very powerful, my favorite is this part.
  • Built-in powerful tools, the go language inside a lot of tool chain, the best should be gofmt tools, automated format code, can make the team review so simple, the code format is identical, it is difficult to think differently.
  • Cross-platform compilation, if you write the go code does not contain CGO, then you can do the window system to compile the application of Linux, how to do it? Go refers to the Plan9 code, which is information that does not depend on the system.
  • Embedded c support, said the author is the author of C, so go inside can also directly contain C code, using the existing rich C library.
2, go suitable for what to do
    • Server programming, if you used C or C + + to do things, go to do a good job, such as processing logs, data packaging, virtual machine processing, file system and so on.
    • Distributed systems, database proxies, etc.
    • Network programming, which is currently the most widely used, including Web applications, API applications, download applications,
    • In-memory database, some time ago Google developed groupcache,couchbase part of the build
    • Cloud platform, at present, many foreign cloud platform in the use of Go development, cloudfoundy part of the formation of the former Vmare technical director himself out to engage in Apcera cloud platform.
3, go successful project
nsq:bitly open source Message Queuing system with very high performance, currently they process billions of messages per day
Docker: A virtual packaging tool based on LXC that enables the creation of PAAs platforms.
Packer: Image files used to generate different platforms, such as VMS, VBox, AWS, etc., author of vagrant
Skynet: Distributed scheduling framework
Doozer: Distributed synchronization tool, similar to zookeeper
Heka:mazila Open-source log processing system
Cbfs:couchbase Open source Distributed File system
Tsuru: Open source PAAs platform, identical to the functionality SAE implements
Groupcache:memcahe written by the author of the cache system for the Google download system
God: A Redis-like caching system, but with distributed and scalable support
Gor: Network traffic capture and replay tool
Here are some companies, just a few:
  • http:// apcera.com
  • / http stathat.com
  • Juju at Canonical/ubuntu, presentation
  • / http Beachfront.io at Beachfront Media
  • CloudFlare
  • Soundcloud
  • Mozilla
  • Disqus
  • / http bit.ly
  • Heroku
  • Google
  • Youtube
Listed below are some of the users used
Gousers-go-wiki-a List of organizations that use go.
4, go also existing shortcomings
The following disadvantages are some of the problems I have encountered in project development:
    • Go import package does not support version, sometimes upgrade is easy to cause the project is not operational, so you need to control the corresponding version information
    • Go Goroutine once started, the switch between different goroutine is not controlled by the program, runtime scheduling, need rigorous logic, otherwise goroutine sleep, over a period of time logic ended, suddenly came out and executed, will lead to logic error and so on.
    • The GC delay is a bit large, I developed the log system hurt once, at the same time concurrency is very large case, processing a large log, the GC is not so fast, memory recovery is not a force, and later through the profile program improved after the improvement.
    • Pkg under the picture processing library a lot of bugs, or the use of mature products good, call these mature libraries ImageMagick interface more reliable


Finally, it is recommended that you learn go, the language is really worth learning, because it can do from the bottom to the front of any work.

Learn go words welcome everyone through my book to learn, I have open source on GitHub:
Astaxie/build-web-application-with-golang GitHub

And if you use API development or network development, then I do open source framework Beego may be suitable for you, can be appropriate to learn:
Astaxie/beego GitHub
  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.
Related Article

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.