"Go" why use go; Golang Erlang Past Life

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Give yourself a retreat and compare Erlang and Golang again.

2014-6-28

Chen Yehao chenyehao@gmail.com

Rainy weekend, suitable for the season of the code word ...

A year ago, when I began to learn the go language, unsanitary environment, both Python coding efficiency and 15 times times the performance improvement. Especially in the area of asynchronous programming, you can use channel synchronization threads, without locking can make full use of CPU multi-core computing, there is no weakness.

It was then slowly learned that the idea of this unlocked asynchronous programming, derived from a language called Erlang, was even more remarkable. In addition to asynchronous programming, the language natively supports distributed, software developed on a single machine that can run unmodified on a cluster, and also supports a hot upgrade of the software version, with its own OTP framework that supports monitoring and rebooting between processes, providing a rock-solid operating environment. Erlang is so perfect, I think it is the most suitable language for developing Internet applications, and for a time there is the joy of "finally finding the truth".

But at that time, the heart always feel there is something wrong, that is, seven Bull CEO Xu Xiwei itself is a master of Erlang, he chose the go language for their company, seven cattle to become a only use the go language to develop the company.

In recent days, with Erlang learning in depth, the answer is slowly found. Erlang Essence is a dynamic language, its dynamic type, dynamic function call, all fully express the characteristics of dynamic language. Erlang is a dynamic language running in a virtual machine, it is not surprising that only dynamic language, it is easy to implement the software version of the hot upgrade. What is the disadvantage of dynamic language, is slow, dynamic language because of the time to type deduction, execution speed is more than static language several times slower, so, the optimization of Erlang itself is to use the common functions in C language, as far as possible to integrate into the virtual machine of Erlang, as for the programmer to write code, Can only be carried out slowly.

So Erlang is suitable for scenarios that are high concurrency and computationally dense, such as WhatsApp, written in Erlang, tens of thousands of users simultaneously online, high concurrency typical scenarios, but the message is not dense between users, how fast a person can type, this scene is particularly suitable for Erlang.

Xu Xiwei Long understood, seven cattle to provide the picture cloud storage, always need large disk IO, picture real-time scaling requires a lot of CPU computing, choose the static language go language, can improve performance, reduce the purchase of the server.

"In the world, the law, the Tathagata does not bear the Secretary", high concurrency and dense calculation is actually a pair of contradictions, when the CPU services in dense computing, naturally flawless response to more requests. Of course, you can use Erlang to build an Internet service, respond to highly concurrent requests, and then transfer the computation to a CPU-free node, but those compute nodes, if written in a static language such as the go language, get better performance.

In the design of the software, the microscopic, to identify which can be concurrent, which must be serial. On the macro level, you want to identify which IO is dense and which are computationally intensive. There is never a standard answer, it is the charm of this industry.

Comparison Summary:

The advantage of Erlang, where the 2,3,4 and no other language can rival

1. High concurrency, the originator of asynchronous programming, writing concurrency code is very simple

2. Support Cluster

3. Robustness (OTP process monitoring mechanism)

4. Code hot upgrade, Hot rollback

The advantages of the Go language (scala,f# similar),

1. High concurrency, support asynchronous programming

2. High performance (the advantage of static language)

Http://blog.sina.com.cn/s/blog_6e1bd8350102uwgl.html

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.