📜 ⬆️ ⬇️

Erlang. What is it, why, how and for whom.

The article is short, if you like, I will try to cover this programming language in more detail.

what



Erlang is a functional programming language with dynamic typing, the main feature of which is programming at the level of individual processes (almost analogous to threads in other PLs), communication between which is implemented using MPI (Message Passing Interface).
')


What for



The increase in the frequency of the central processors stopped. The number of cores and the number of nodes in clusters is growing. Erlang is designed to simplify the development of programs that can use the full power of multi-core and / or multi-node systems.

Successful examples of using Erlanga - Jabber (hooray!) Ejabberd server, YAWS web-server and numerous experiments, for example, a comet-program (a specific web site programming style, when the server does not break connections with the client, but continues to send data to it if necessary) keep 1,000,000 (million) tcp connections.

I will not give any comparisons, suffice it to say that these programs can withstand a furious load and are very resistant to attempts to kill them :)

how



Programming at the level of separate, isolated processes gives many advantages over the usual style of programming parallel software.

Let's start from the beginning - why is it difficult to program such software in Jave, C or Sharpe? The problem is very global and exists in all these languages ​​- memory sharing. When programming on these PLs you cannot be sure that the memory capacity where your variables are referenced has not changed any other thread (thread, thread, thread ...). Because of this, it is often necessary to resort to various, time-tested tricks - lokas, mutexes, semaphores. And it is difficult to do. It is difficult not only for a beginner programmer, but also for a programmer with experience on which the performance of the system depends, if several other experienced / inexperienced programmers are working on it.

Generally speaking, the problem is not solved in Erlang. It is simply isolated to a level below the language itself. Each process is isolated and does not have access to the memory of other processes.

In a nutshell: if there is no shared memory, then there is no problem with access to this memory.

For whom



Erlang is very easy to learn, you can understand the syntax in a day or two, the principles of programming are a week or two. But the programming paradigm is quite complicated and switching to it (especially if there is a huge experience in imperative PL) is quite difficult and sometimes you don’t feel like it. Not once heard - how can you program with non-objects? The whole world consists of objects and interactions between objects! The answer is simple - the whole world consists of processes and interactions between processes as much as it consists of objects.

With the use of this PL, many problems are solved trivially, and I believe that Erlang is the best PL, from which it is worth starting familiarity with functional languages. Especially if programs need to be parallelized and clustered.

Source: https://habr.com/ru/post/50028/


All Articles