How does Elixir compare to Ruby

For Erlang there are drivers for most of the common persistence technologies. As usual, you can flexibly choose between the NoSQL databases depending on the application. As a beginner, however, you shouldn't resort to familiar methods too quickly, because Erlang also has its own database systems up its sleeve. For example Mnesia, which should definitely be considered due to its performance, memory consumption and degree of maturity.

Erlang, the eternal underdog among programming languages?

Those who change or are new to it are quickly confronted with the special character inherent in Erlang. Other platforms, for example, tend to abstract and encapsulate standards such as HTTP through frameworks. As an Erlang developer, on the other hand, you are encouraged to deal with the basic technologies. This feels rougher and rougher at first, because you're more likely to find yourself leafing through an RFC (Request For Comment) specification than consuming a nice framework tutorial.

However, the result of this approach is a deep understanding of the technologies that are used in everyday development. At this point, developers could fear that they would be forced to produce tons of source code and that the development and refactoring themselves would be very time-consuming. But exactly the opposite is the case. The Erlang language itself is very economical and gives you the OTP toolset, which provides solutions and patterns, so-called behaviors, for the most common problems.

Perhaps it is due to this bulkiness, which some users certainly perceive, that Erlang is still not very well known in Germany. While the spread was limited, Erlang has proven itself time and again over the years to be a stable and “battle-proven” alternative. Multicore CPU architectures, reliability, parallelism on the web: these cutting-edge topics are better addressed by Erlang than by most other platforms. So the only thing that could seem old-fashioned about Erlang would be the programming language itself - which doesn't look really accessible at first glance.

Peculiarities of the language

This is not only due to the lexical system and syntax, but also to the peculiarities of functional programming languages. The structure of the code in Erlang is fundamentally different from what many developers know from object-oriented or procedural languages. For example, instead of loops, tail recursions are used or messages are assigned to the functions with pattern matching or data groups are defined. Tail recursion is often used as a replacement for iterations in functional languages. In contrast to a naive recursion, the storage space consumption does not increase with every further recursion and is therefore both functionally intact and efficient. Pattern matching uses the symbolism and structure of arguments to resolve them and is very intuitive.

Of course, Erlang is also not a silver bullet with which all problems can be solved. Basically, number crunching, i.e. the processing of many numbers, is seen as a weakness of Erlang. On the one hand, this is true because there are technologies that master this more efficiently - on the other hand, this only applies to calculations that cannot be parallelized. In the case of a large number of small, non-sequential calculations, the strengths of parallel processing can again predominate.

The biggest weakness of Erlang, however, is its demographics: While companies can usually acquire new Java developers directly from universities, there are comparatively few Erlang developers on the market. This not only makes staffing particularly difficult, but also increases the dependency on staff or individual service providers and thus the risk.

Elixir: Erlang becomes attractive

However, with Elixir that could change in the future. The functional, concurrent programming language Elixir compiles exactly like the language of Erlang so-called beam bytecode, which can be executed on the Erlang VM. Elixir thus benefits from the advantages of Erlang's basic technology and runtime environment, but is modern and accessible - especially for a large number of Ruby developers, who are attracted by the similar conception with higher speed and scalability. The following code example illustrates the differences between Erlang and Elixir:

Hello World in Erlang

Hello World in Elixir

A comparison of the differences between Elixir and Ruby can be found on Github. The Elixir community has also put itself in good shape with the help that is available for entry or change. No comparison to the less attractive documentation by Erlang himself: With podcasts and colorful, beginner-friendly web tutorials, you can quickly find access. The entry barrier of the Erlang language was largely shelved with the release of Elixir. Companies such as Pinterest or the marketing software Moz are already relying on Elixir, and v1.7 of the language released in July 2018 has been downloaded almost 300 million times.

In this context, the Phoenix framework developed by Chris McCord comes into its own, which is currently available in a stable v1.3: a web framework programmed in Elixir for the Erlang VM, which is ideal for creating powerful and highly available web applications. Phoenix is ​​heavily based on Ruby on Rails or Django from Python and therefore offers a lot of recognition value. Even Java developers should be familiar with one or the other server-side MVC framework and find their patterns there.

The rapidly growing Elixir community is moving Erlang more and more into the spotlight. It can therefore be expected that IT decision-makers will no longer have to fear demographic risks and instead benefit from the stability, scalability and speed of development of the Erlang ecosystem. Despite Elixir and Phoenix, it is advisable to first start with the Erlang language and the OTP framework for the deepest possible understanding of the core technology. A variety of stable development environments are available for those interested. If someone feels at home in Emacs, it is advisable to develop Erlang there as well. But it is nicer with Intellij, Sublime or Eclipse. Erlang provides its own toolbox for managing dependencies and performing test cases.

The author

Frank Hinkelis managing director of Neozo GmbH & Co. KG and realizes projects with a focus on lightweight and scalable software architectures.

The author

Jean Michel Malatrayworks at SSI Schäfer Shop GmbH as a full-stack developer. His focus is the development of e-commerce systems based on micro-services and self-contained systems.

You might be interested in that too