Elixir vs Ruby on Rails

This is accurate and it’s both a strength and weakness of Ruby. Ruby is a malleable language and Rails (at least early on, I don’t know if this has changed) actually modifies the language itself to make it friendlier for web development. Adding functions like .blank? to the root string object is a simple example so you can say " ".blank?.

On one hand, this is a super power. I can inject a function directly into the root String object and make it available everywhere (or change behavior everywhere) without having to fight the entire inheritance tree. This is especially valuable when dealing with 3rd party libraries, both for adding quick fixes without having to fork/branch the entire library while you wait for a PR to be approved…and for making 3rd party libraries easy to use because they can easily inject themselves at the appropriate places within your code base. It’s the closest thing to workable Aspect Oriented Programming I’ve ever encountered. When dealing with huge inheritance trees in OOP, the ability to fix something at level 3 without having to rework the entire hierarchy is awesome. There are, of course, many trade offs and negative consequences to it as well.

Elixir doesn’t do anything that you don’t tell it to do. It’s more explicit. The functional paradigm also entirely avoids the OOP hierarchy entanglement where such approaches are beneficial. When you don’t have to worry about a function call transforming a value that you can’t see, hidden within a stateful object, the functional approach simplifies explicitly calling everything and leads to much easier long term maintenance.

2 Likes