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

The difference between erlang and golang

(*-*)浩
(*-*)浩Original
2019-12-02 15:49:154952browse

The difference between erlang and golang

The difference between Erlang and golang:

The first has a different attitude towards locks, the second has a different attitude towards asynchronous IO, The third message mechanism is different. 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. of.                                                                                                                                                                                                                                                                                                     Golang's server is different. Golang's server is a server composed of multiple processes (goroutine). 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, and each server will not interfere with each other. They can 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 for 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 erlang and golang. 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