Erlang Developer Arsenal

Good time of the day, dear audience of a habr.

In this publication, I wanted to describe my experience with moving from enterprise Java to Erlang.

Dives in Erlang as a first approximation

Recently, I began to notice that more people are waking up interest in functional programming. Many people in this area of ​​development leads to a purely academic interest, some try to solve problems with more suitable means, while others simply encounter this on new projects.

After quite a long time of Java / Python development, I decided to radically change the scope of activity and discovered Erlang.

After the multi-threaded Java helper, Erlang proposed a more accurate and less resource-intensive model for solving the multithreaded programming problem - the actor model.

This model, of course, has its minuses and pluses, but the functional paradigm and the absence (or control) of the side effect significantly complement each other.

Although it is worth noting that the "real" multithreading was introduced in Erlang relatively recently, in 2006. After the implementation of SMP (Symmetrical Multi Processor) inside Erlang VM.


This implementation is dated 2008, unfortunately I did not find a description of the latest implementation, but most likely they left the shared queue for all schedulers.
In short, SMP support allows you to use from 1 to 1024 process schedulers that work inside each thread. Schedulers take Erlang processes and IO tasks out of a 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 the developers even then planned to move away from the general task queue to the queues for each scheduler.

Build and Deployment Tools

When moving from a well-bred Enterprise Java world, where there is almost everything you need under any licenses, you just need to think about it, and it already lies somewhere in the open source. I came across 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 has become the very platform where Erlang projects are published.

I suggest that you familiarize yourself with the list of Erlang developer work without which it is very difficult.

Let's start with automation tools for deploying the platform and building the project.

Kerl

Without this script, it would be very difficult to test your applications on different versions of Erlang. It allows you to assemble the Erlang build you need from the source, adds it to the global list, allows you to install the assembled build in the necessary directory and after that it is very convenient to switch between builds.

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

We collect 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 (r , please wait ...
Erlang / OTP R14B02 has been successfully built

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

We 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 performs assembly, compilation, and dependency management also from version control systems.
There are several articles on using rebar and pretty good documentation.

Typical use case


I just go through the main commands:

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

Update Dependencies
$ rebar update-deps

Assemble project
$ rebar compile

Generate release
$ rebar generate

Clear build artifacts
$ rebar clean


It is worth noting that this tool has long become the standard when working with projects on Erlang. I would very much like Ericsson to introduce it into standard OTP.

IDE tools or word processors

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

After a short search, some plugins were found.

Eclipse



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

  • dialyzer support
  • wrangler support
  • etop support
  • eunit support
  • debugger support (remote)


There is also a fairly convenient refactoring and search.

IntelliJ IDEA and Erlang plugin authored by Sergey Ignatov.



  • navigation
  • auto completion
  • rebar support (!)
  • eunit support
  • dialyzer support
  • wrangler support
  • debugger support


And what tools do you use when developing on Erlang?

Also popular now: