107
votes

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.

4
@hedgehog not an opinion, fact. question is "My question is if I choose Elixir, will I stumble on something that I can not do it, but can do in Erlang? Can I use all OTP stuff, all Erlang libraries, code reload, etc. with Elixir?" and the answer is based on facts not opinion.Saša Šijak
For that question, the answer is: everything you can do in Erlang is possible in Elixir. But the title suggests that the question is what should you invest in and here the answer is "it depends". What do you want to do? For web applications Elixir is much nicer, because it was created to solve this problem. For some kinds of distributed systems you can find simplicity of Erlang superior. Lack of features is often the good thing. Learning only Erlang will help you focus on the most important bit: OTP.tkowal
@SašaŠijak I changed the title of the question, to IMO better reflect what it's about - revert if you don't agree.Paweł Obrok
@PawełObrok great edit, it rightly summarize what I was interested to knowSaša Šijak
everytime i make these kind of questions i get -10 downvotesarisalexis

4 Answers

39
votes

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.

66
votes

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)
38
votes

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.

5
votes

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