Home >Backend Development >Golang >The difference between golang and erlang

The difference between golang and erlang

(*-*)浩
(*-*)浩Original
2019-12-13 11:52:153916browse

The difference between golang and erlang

Erlang The first version was launched to users by Ericsson in 1991. After continuous improvement, improvement and development, in 1996 In 2008, Ericsson provided a very practical and stable OTP software library for all Erlang users and released the first open source version in 1998. (Recommended learning: go)

Currently, the operating systems supported by Erlang include linux, windows, unix, etc. It can be said that it is suitable for mainstream operating systems, especially its multi-core support It is very suitable for current multi-core CPUs, and the distributed characteristics can also be well integrated with various current distributed clusters.

Go language is another attempt at programming language design and a major improvement to C-like languages. It not only allows you to access the underlying operating system, but also provides powerful network programming and Concurrent programming support. Go language has many uses and can be used for network programming, system programming, concurrent programming, and distributed programming.

The launch of Go language aims to reduce the complexity of the code without losing application performance. It has the advantages of "simple deployment, good concurrency, good language design, and good execution performance". Currently, many domestic IT companies have adopted Go language to develop projects.

The difference between Erlang and golang:

The first has a different attitude towards locks, the second has a different attitude towards asynchronous IO, and the third has a different message mechanism. Erlang is very averse to locks and believes that immutable variables can avoid locks to a large extent.

Golang's point of view is that locks do have a huge burden, but locks are basically unavoidable. Once someone shares the state and preempts each other to change it, the lock must exist.

The Erlang server is a single process, and there is no logical concurrency. A Process is an execution body, so the Erlang server is different from the golang server. The golang server is multi-process (goroutine). Together they form a server. Each request creates an independent process (goroutine).

But Erlang is different. A server is a single process. All concurrent requests enter the process mailbox. Then the server takes the mail (the content of the request) from the process mailbox for processing. Erlang's server does not have concurrency. request, so no lock is required.

Erlang's high concurrency implementation, first: each Erlang physical server will have many servers, each server has no interference with each other, and they can be concurrent. The second is that a single server uses asynchronous IO for high concurrency.

Go believes that there should never be asynchronous IO code, while Erlang is a mixture of asynchronous IO and a lightweight process model.

Golang’s support for concurrency, first: value return, the most important thing about golang is to reduce execution costs, the minimum stack of golang can be 4K.

Second: Use the executable body as a standard facility built into the language (golang has only one standardized code style). Go's concurrency model is the oldest concurrency model. The concurrency model includes routines, atomic operations, mutexes, synchronization, messages, and synchronous IO.

The above is the detailed content of The difference between golang and erlang. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Is golang chan closed?Next article:Is golang chan closed?