Why did José Valim create Elixir?
An interview with José Valim in a Brazilian podcast suggests an answer: read the excerpt below.
Carlos Brando (CB): Valim, you’re not here for nothing. You’re here to save us from the ugliness of the Erlang syntax. What is this idea? What project are you developing on top of Erlang?
José Valim (JV): This is a funny story. When one person heard about this project, she asked, “Man, how can you cope with Erlang? It’s very ugly.”
I said: Dude, I think I only develop in Erlang because the first thing I read was about the Erlang Virtual Machine. It was not the language. If the first thing I had seen was like a gist or a paste of the language I would have given up.
Rafael Rosafu (RR): It’s horrendous, it’s horrendous.
JV: Erlang, its syntax, if you want to blame someone, blame Prolog. Have you ever used Prolog?
RR: No, I did not use Prolog.
JV: I had a teacher who liked Prolog so I ended up having some meetings with Prolog. There are things that are very strange. I think for me the worst part, even more being a Rubyst, is the punctuation part. You have to end some expressions with a comma. You have to end methods with a point. In some specific points, like an “if-else”, a “case”, you have to put a semicolon (;). Except that you put a semicolon in almost all clauses except the last one.
RR: At the last clause, a point?
JV: It’s nothing. At the last clause, you put nothing.
RR: I remember it was very bizarre. It was horrible to read. The difficulty of understanding functional code for those who are not accustomed is not enough. You always have to deal with that horrible syntax!
CB: And there are things that are… The “if” does not work like a normal Ruby’s “if”, which you use in Ruby or in other more common language like Java, etc. The Ruby’s “if”, C’s “if”, would be equivalent to the Erlang’s “case”. Erlang’s “if” has another purpose.
JV: Erlang’s “if” works as follows: for each expression <”if” “such thing”>., each “if” expression must necessarily return “true”.
CB: Either “true” or “true”. (laughs)
JV: Either “true” or “true”. So when you have an “if” you will put multiple clauses. If at the time of executing all the clauses, none is “true” it will return an error. So you have to put that last clause of your “if”, the “else” in Erlang, is a “true”.
I had a bad arm so I took the opportunity to write another programming language. One of the points was exactly to improve the syntax. We can do a better syntax here, you do not have to think too much. The other point, at first I thought: I think I’m missing object orientation. I was working on this idea a little and saw that it was not a lot of object orientation. I was missing out on method dispatching. In Erlang you can not get a structure and say: I’ll call a method on it. You do not have polymorphism in this sense. You simply have to call module’s methods. I can not do this in Erlang: I have a list and I want to add another one. You have to call the module, for example, the Lists module, and call “concat” or “append” and pass the two lists as a parameter. As you write code, it gets repetitive. I was really missing it. The code gets more verbose. It takes away the expressiveness of the code.
RR: Looks like the things we wrote in Clipper.
JV: It reminds me of C too. Whenever you call a function you have to pass all objects that are involved there.
RR: I did not have the opportunity to program in C when C was more common. I had to program in fourth-rate language like Clipper. That horrible thing.
PS: Twitter thread that gave origin to this post: