Understanding Elixir/Phoenix performance

There are definitely cases where Ruby will outperform Elixir. For example, Ruby’s compact is implemented in C, while in Elixir we have to iterate a linked list in Elixir code. Ruby will inevitably work faster here (though Elixir will have some other benefits, such as non-blocking code).

Another thing going for Ruby’s performance is mutability. Yes, mutability is usually bad, and even though I’ve spent more than half of my programming life happily working with mutable data, I agree that immutable is a saner default in most cases. Regardless, there are occasional scenarios where mutability will do wonders for performance.

So I wouldn’t generalize that either is faster, and TBH it usually doesn’t matter. As I like to say (and I already said it here), if proper algorithmical and technical optimizations are done, the differences between any two languages frequently become irrelevant in practice. At least that’s my own limited experience. If the performance is still not good enough and we want to squeeze out every nanosecond, than neither Ruby nor Elixir are likely good choices, and hence the comparisons of their performances is IMO usually not very interesting or useful :slight_smile: