Go language Advantages and main uses

Source: Internet
Author: User
Tags couchbase
This is a creation in Article, where the information may have evolved or changed.
1, go what advantages 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 on the 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 is suitable for what server programming, before you use C or C + + to do those things, with go to do very appropriate, such as processing logs, data packaging, virtual machine processing, file system. Distributed systems, database agents and other network programming, this one is currently the most widely used, including Web applications, API applications, download applications, memory databases, some time ago, Google developed a part of the groupcache,couchbase to build a cloud platform, At present, many foreign cloud platforms 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, the performance is very high, currently they deal with billions of messages per day Docker: A virtual packaging tool based on LXC, enabling the creation of PAAs platforms. Packer: Image files used to generate different platforms, such as VMS, VBox, AWS, ETC., the author is the author of vagrant Skynet: Distributed scheduling framework Doozer: Distributed Synchronization tool, Similar to Zookeeperheka:mazila open source log processing system Cbfs:couchbase open source Distributed File System Tsuru: Open source PAAs platform, And the functionality of the SAE is exactly the same as the Groupcache:memcahe author's caching system for Google downloads God: A Redis-like caching system, but supports distributed and scalable GOR: network traffic capture and replay tools

  • 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.
  • 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.
  • 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.
  • 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.