re: Elixir vs Ruby - where to use? VIEW POST

FULL DISCUSSION
 

This is a really great exploration of the relative advantages, thanks! I'm going to refer to this the next time I think Elixir would be a good fit for a project.

I love Elixir, but when I suggest it for projects people always ask "Why not Ruby?" The community and supporting projects in the Ruby ecosystem is just so many years ahead of Elixirs', and there are also so many uncommon common concepts to learn in Elixir.

The concepts I see people struggle with are some of Elixir's greatest strengths, so I think when developers become more comfortable with the language and the motivation behind its design, many of its perceived disadvantages will become advantages, like these:

  • no for loops -- this isn't an advantage by itself, but I think it is a good decision to encourage more use of recursion
  • function dispatch based on pattern matching -- there's nothing like it in other languages, but it encourages smaller functions with less complex conditionals
  • managing concurrency, state, and errors using GenServer -- there are so many concepts to put together for this, but it's a rare example of a truly reliable and fully encapsulated abstraction (unlike leaky objects)

You listed "smaller ecosystem" as a con for Elixir, but I think it can be a pro also. I couldn't find an Elixir-y SQLite client library so I built one and it ended up getting a bunch of downloads. Having a smaller but growing community makes it feel more fun and full of opportunity to me. For example I love Python too, but to make a real contribution to that ecosystem (like Ruby's) I couldn't just write an SQLite library.

 

Hi, Eli! Thanks for your comment! That all really make sense and I agree with you. Sometimes we just use stereotypes to consider something to be pros or cons. In this case, a smaller ecosystem can really be a great thing from that point that every single developer can contribute and make an impact. I hope that your SQLite library will attract more attention and users! Good luck to you!

 

no for loops -- this isn't an advantage by itself, but I think it is a good decision to encourage more use of recursion

Recursion is not what you want to encourage.

List comprehensions and Stream combinators, where the iteration pattern is abstracted away, are what you should be encouraging. They're way more readable than recursive functions.

 

Actually there is for & foreach loop

for n <- 1..100 do
   ...
end

This for loop uses shadowing.

code of conduct - report abuse