Are there things Elixir can do that Erlang cannot, or vice versa?

ErlangElixirErlang Otp

Erlang Problem Overview


This question is in the context of the Beam VM and the capabilities that it provides, not in the general context of what a Turing complete language can do. I want to invest some time to learn either pure Erlang or Elixir. I get the basic differences between the two and I am leaning towards Elixir because of the macros, better syntax and faster development of the language this day.

My question is: if I choose Elixir, will I stumble on something that I cannot do in it, but can do in Erlang? Can I use all the OTP stuff, all the Erlang libraries, code reload, etc. with Elixir?

I am not asking for someone's preference between the two; just facts about the possibilities of the languages. Preferably from someone who used both in production.

Erlang Solutions


Solution 1 - Erlang

You shouldn't stumble on anything you can do in one that you can't in the other, since you can freely call Elixir code from Erlang and vice-versa. You can even easily mix Erlang and Elixir files in one project.

In Elixir:

:erlang_module.erlang_function(args)

in Erlang:

'Elixir.ElixirModule':elixir_function(args)

Solution 2 - Erlang

Just to preface - I have only used Elixir in production and not Erlang.

I would honestly recommend Elixir. This is my opinion and not necessarily the right one for you, but below I will list my reasons why.

  1. Productivity: I come from a Ruby/Rails background so the Elixir syntax and style is something that was very familiar to me. One of the main factors that helps me determine whether or not to learn a language is how productive I can be in it - mainly why I chose Ruby. Elixir is the same. I can work just as fast in it as I can Ruby with all the added benefits of concurrency and pattern matching.
  2. Erlang: Since Elixir is built on top of Erlang and compiles down to erlang and the beam vm, you have access to every erlang module and package. So if you are worried about using elixir and missing out on all of the features of Erlang, you shouldn't be. Elixir even has it's own implementations of most of the bigger Erlang/OTP features such as GenServer, GenEvent etc.
  3. Community/Resources: The Elixir community is really a great one. The slack channel is really popular and great way to get some answers for beginner questions. There are already some really good books written on the language (Programming Elixir 1.2 - Dave Thomas, Author of the Ruby Pickaxe) also that make getting into the language really easy.

Really, if you have a mess around with the two you will probably come to the same decision that Elixir is a much nicer language with all the features of Erlang + More. It's on the rise as well, I can't remember the exact numbers but I remember reading something from the Hex website (package manager) about a considerable increase in package downloads.

Solution 3 - Erlang

TL;DR - Start with Elixir

Erlang has a steeper learning curve compared to Elixir. Once you start learning Elixir, you will automagically start learning Erlang. Hence, start out with Elixir. Elixir is written in Erlang and Elixir. See distribution on Github (since Elixir is full of macros aka meta-programming). Elixir Project Code distribution

You can use Elixir with Erlang and vice-versa, hence the full Erlang eco-system of 20+ years of libraries.

More details from Erlang Solutions

> Elixir’s ‘out of the box’ productivity is accomplished by a strong focus on tooling and convenience in expression of data manipulation. System design is the same in Elixir and Erlang, but Elixir removes a lot of boilerplate code and is easier to extend. The removal of boilerplate raises productivity and allows programmers to get feedback faster – crucial when you want to launch your product to market as fast as possible. Less boilerplate also makes for happy developers, and happy developers are unsuprisingly productive developers.

Joe Armstrong's (Erlang inventor's) blog post about Elixir

Start here to learn about Elixir - Getting Started

Once you feel its going well, work your way towards practicing on Exercism and other resources.

Solution 4 - Erlang

There are a few things. I think you can't make a recursive anon function in Elixir. Now to be fair this is something that in 8+ years of Erlang I don't think I have ever needed to do, and if I did it could be done easily in some other way. There are probably a few other things like that that quite honestly you can ignore.

In general, for things that most people care about anything you can Do in Erlang, you can do in Elixir and vice versa. The community on the Elixir side seems to be more active so I would suggest starting there. I have recently moved from Erlang to Elixir and with the exception of a few fancy things in Proper I can say that it is a pretty easy transition

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSaša ŠijakView Question on Stackoverflow
Solution 1 - ErlangPaweł ObrokView Answer on Stackoverflow
Solution 2 - ErlangHarrison LucasView Answer on Stackoverflow
Solution 3 - ErlangSairamView Answer on Stackoverflow
Solution 4 - ErlangZachary KView Answer on Stackoverflow