by pjmlp · 9y ago · 0 comments
Basically it looks like the escape route for Ruby developers that care about performance.
Ruby really isn't designed for building complex concurrent systems. Erlang/OTP is designed specifically for that.
When I need to build something that recovers from failures in Rails, it means code that is littered with try/catch statements. I recently wrote a basic caching system in Elixir for a project at work. There are plenty of ways for it to fail, and I handle none of those situations. I let it crash, bring it down gracefully, and then bring it back up in a healthy state. You can write truly fault-tolerant programs on top of a very powerful and stable VM.
If I ever would need BEAM, Erlang would be quite ok, given that I was quite comfortable with Prolog in the past and do like the syntax.
Hence why I kind of see it as BEAM for Ruby developers, even if I am way off what is actually happening on the BEAM world.
The use cases for OTP are actually quite narrow, despite what Erlang/Elixir evangelists tell you.
Discord is a fantastic use for OTP. Writing a CRUD app with a couple of reactive/interactive pages for comments on videos and few thousand users, OTP is overkill.
If you have an app that needs the scale and safety of OTP, then which language you pick makes no difference.
Phoenix is a really cool project, written by great developers and the community is probably the nicest and most helpful you will ever meet. But how many companies/projects need the performance and redundancy of Phoenix/OTP in their web application at the cost of not being able to hire developers?
I just type "mix phoenix.new <project name>" and I have a relatively light starter framework that's ready to go as far as I need to take it.
Rails had the same "ready to go" feel as Phoenix, but I learned from painful personal experience that you hit the scaling wall way too quickly - but with that project I never realized that scaling would ever be a problem. How was I supposed to know which sized framework/language to use from the beginning.
So sure, the use cases where OTP will really shine for you are potentially narrow. But Elixir is actually quite fun to work with even for small projects and it's fantastic knowing that if a project grows unexpectedly, I don't have to scrap it and write it in something else.
I like to describe Elixir should suit well anything that runs on top of a TCP socket. A binary protocol, an HTML app, a JSON API or even a distributed system. Embedded systems is coming up as a new area of interest as well.
I wouldn't say those cases are narrow. But I believe you meant the use cases are narrow if you are already using other platforms. Then indeed we have many things to consider beyond the technical aspects.
But I also would like to argue that scale and safety are not the only reasons to try Elixir and OTP. I personally find functional code easier to maintain, especially because of immutability. The performance aspects really shows up during development and testing as well. I wrote a bit about the latter here: http://blog.plataformatec.com.br/2017/07/the-fallacies-of-we...
I asked him, "One thing I like to do as a programmer is learn a new language every year or so, especially a language that teaches me something new about programming. Ruby was very good for this, of course, along with some of the other languages I've learned. Is there a language you've tried out lately that gives you that feeling of learning a new way to program?"
Matz said, "Elixir". He explained why; I don't remember the details but it stuck in my mind as a language to check out.
BTW, if you've ever seen the acronym MINSWAN, or "Matz Is Nice So We Are Nice", it's really true! A very nice guy.
https://www.flickr.com/photos/geary/10218307085/in/photostre...