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

Source: Internet
Author: User
Tags couchbase

The Go language official claims to have developed the go language because "it's been a bit frustrating to develop programs in the last 10 years." This positioning implies that the go language wants to replace the status of C and Java and become the most popular common development language.

Programming language has been very many, biased performance-sensitive compiler language has C, C + +, Java, C #, Delphi and Objective-c, and so on, the rapid business development of dynamic analytic language has PHP, Python, Perl, Ruby, JavaScript and LUA, etc. There are Erlang, R, and MATLAB for specific areas of language, so why do we need a new language like go? Let's take a look at the use of the go language in Western countries in the last three years, and Jay can only say that it has soared and soared faster than Python! What are the advantages of the go language compared to other languages?

Recommended Go language Learning course: Go language from beginner to advanced combat

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.

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?

1, go refers to the Plan9 code, which is not dependent on the system information. 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., 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 extensible Gor: network traffic capture and replay tools here are some companies, just a few.

4, go also exist shortcomings of the following shortcomings are my own in the project development encountered some problems: Go Import package does not support the version, sometimes upgrade is easy to cause the project is not operational, so you need to control the corresponding version of the Goroutine once started, Switching between different goroutine is not controlled by the program, runtime scheduling, the need for rigorous logic, otherwise goroutine sleep, over a period of time logic ended, suddenly came out and executed, will lead to logic errors 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 everyone learn go, this language really deserves everyone to learn, because it can do any work from the bottom to the front.

Recommended Go language Learning course: Go language from beginner to advanced combat

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.