📜 ⬆️ ⬇️

Battle Arsenal of Erlang Developer

Good time of day, dear audience habr.

In this publication, I wanted to describe my experience in switching from corporate Java to Erlang.

Erlang dives in first approximation

Recently I began to notice that more people are waking up with interest in functional programming. Many in this direction of development leads to purely academic interest, some try to solve problems with more appropriate means, while others simply encounter this on new projects.
')
After quite a long time Java / Python development, I decided to radically change the scope of activities and discovered Erlang.

After a multi-thread Java healer, Erlang proposed a more accurate and less resource-intensive model for solving multi-thread programming problems - the model of actors.

This model certainly has its drawbacks and advantages, but the functional paradigm and the absence (or control) of the side effect complement each other significantly.

Although it is worth noting that the “real” multithreading was introduced into Erlang relatively recently, in 2006. After implementing the SMP (Symmetrical Multi Processor) inside the Erlang VM.


This implementation is dated 2008, unfortunately I did not find a description of the last implementation, but most likely they left the shared queue for all planners.
In short, SMP support allows you to use from 1 to 1024 process planners that work within each thread. Schedulers remove Erlang processes and IO tasks from the common queue. In SMP, all shared data structures are protected by locks. The task queue is an example of such a structure. This implementation was described in 2008, and even then the developers planned to move away from the common task queue to queues for each scheduler.

Build and Deployment Tools

When switching from a well-talented Enterprise Java world, where there is almost everything that is needed under any licenses, you only need to think about it, and it already lies somewhere in the open source. I was faced with the fact that in the Erlang world there are a lot of necessary tools, libraries, integration technologies, articles, manuals.

Unfortunately, Erlang does not have a centralized place to store projects and libraries, so github de facto became the very platform where Erlang projects are published.

I suggest to get acquainted with the list of things without which it is very hard for the Erlang developer to work.

Let's start with the automation of the platform deployment and project assembly.

Kerl

Without this script it would be very difficult to test your applications on different versions of Erlang. Allows you to build the Erlang build you need from source, adds it to the global list, allows you to install the build in the required directory and then switch between assemblies very conveniently.

Typical use case


We get a list of possible releases:
$ kerl list releases
Getting the available releases from erlang.org ...
R10B-0 R10B-2 R10B-3 R10B-4 R10B-5 R10B-6 R10B-7 R10B-8 R10B-9 R11B-0 R11B-1
R11B-2 R11B-3 R11B-4 R11B-5 R12B-0 R12B-1 R12B-2 R12B-3 R12B-4 R12B-5 R13A
R13B R13B01 R13B02 R13B03 R13B04 R14A R14B R14B01 R14B02
Run "./kerl update releases" to update this list from erlang.org

Build the selected release as a build:
$ kerl build R14B02 r14b02
Downloading otp_src_R14B02.tar.gz to /home/evax/.kerl/archives
(curl progresses ...)
Verifying archive checksum ...
(curl progresses ...)
Checksum verified (229fb8f193b09ac04a57a9d7794349b7)
Extracting source code
Building Erlang / OTP R14B02 (r14b02), please wait ...
Erlang / OTP R14B02 has been successfully built

Install the build build to the directory:
$ kerl install r14b02 / path / to / install / dir /
Installing Erlang / OTP R14B02 (r14b02) in / path / to / install / dir ...
You can activate this installation running the following command:
. / path / to / install / dir / activate
Later on, you can leave the installation typing:
kerl_deactivate

Find out the list of builds installed in the system:
$ kerl status
Available builds:
R14B02, r14b02
R14B02, r14b02_hipe
- Available installations:
r14b02 / path / to / install / dir
- Currently active installation:
The current active installation is:
/ path / to / install / dir


Rebar

This utility builds, compiles, and manages dependencies from version control systems.
There are several articles on using rebar and fairly good documentation.

Typical use case


I just go through the main teams:

Get all dependencies described in conf file
$ rebar get-deps

Update dependencies
$ rebar update-deps

Build a project
$ rebar compile

Generate release
$ rebar generate

Clear build artifacts
$ rebar clean


It should be noted that this tool has long become a standard when working with projects on Erlang. I'd love to see Ericsson add it to the standard OTP.

IDE or word processors

De facto, Emacs is considered the primary development tool for Erlang.
For fans of Emacs, there are a huge number of plug-ins and extensions to simplify and speed up development, but this approach is not suitable for everyone.

After a brief search, some plugins were found.

Eclipse



The project is developing and at the moment managed to achieve (the list is not complete):



There is also a fairly convenient refactoring and search.

IntelliJ IDEA and Erlang plugin by Sergey Ignatov.





And what tools do you use when developing on Erlang?

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


All Articles