For 6 years I have been creating applications in the Ruby language and the Rails framework. I felt all sorts of new programming languages as they came out, but Elixir is the first one that really fascinated me.
At one time, Ruby made everyone
The Ruby language and the Rails framework have completely changed the way we build web applications. They gave rise to a religion of values for the community of programmers. They were the first to propose the idea that programmer tools should be optimized for productive and joyful development.
They postulated that the task of testing and bringing the code to a working state lies with the developers. Other languages and frameworks scoffed at such an approach until it began to gain popularity. After that, they began to incorporate the principles inherent in the Ruby community into other languages and frameworks.
')

Ruby has gone from a modest position of an unintelligible language to one of the most popular languages, mainly because of the Rails framework and the huge leadership potential of such people as DHH, Wycats, Aaron Patterson, Jose Valim and many others. But periodically, and here and there artifacts are beginning to emerge, which are left because of such a modest start of the language.
Runaway memory
Zed Shaw in the post "
Rails - this ghetto " rant about the problems with garbage collection, because of which the first Rails applications were restarted every 4 minutes.
One of the most popular servers for Rails today is unicorn. My web application is a Rails application, it is quite simple compared to other applications that I developed. I transferred it to the server with 512 MB of memory, and after several days of work, my unicorn ate all the available memory and the application began to slow down.
Decision?
unicorn-worker-killer . Not too different from earlier solutions.
My server is able to serve two unicorn threads, which take most of the resources, the Postgres database, and several other applications. He responds, however, quite quickly, so he does his work.
Parallelism
Although I have been developing Rails applications for several years now, I have never used additional streams in production applications. Rails itself works fine with threads, but according to my feelings, only problems arise from them - I tried to use them in Java, C ++ and other OOP languages.
The bottom line is that I don't want to think about mutexes, semaphores, and so on. If I stop one thread to let the other work, it’s not special, it will be parallelism. And yet - are you exactly sure that the execution of your code does not lead to interlocks?
Testing is the main paradigm of the Ruby community, so it’s not surprising that most rubists don’t touch multi-threading, since it’s almost impossible to test, and its bugs are very difficult to reproduce.
Like most normal developers, I use
sidekiq or
resque to handle things in parallel. In
Rails 2.2, we added security for threads, but in
Rails 4.2 we added the Active Job API, which turned out to be much more useful.
But processes running in the background must be performed in the background. And critical things need to be performed in the main process - so that you can react to an error or make sure that all transactions have been successfully completed before completing the task.
Speed
I am selfish and value my time very much. Therefore, the speed of the tests worries me. I
spent a lot of time optimizing the performance of my test suite without making changes to the architecture of the application and without making any damage to the design because of this.
For a while, it took about 20 minutes to complete the functional and unit tests of the project I was working on. I used hydra for distributed tests, but it was always difficult for me to make the tests pass (most likely because the code is too complex and not very beautiful).
Even running the tests took 40 seconds. Have you ever waited 40 seconds, only to see: “syntax error, unexpected end-of-input, expecting keyword_end”, or the same nonsense? And I was waiting.
What to do?
Zeus . A great gem that preloads everything you need for an application and can download (as described on github) any Rails application in a second. I like him and I recommend him to everyone.
But how did they achieve this speed? Just wrote it on Go.
Scala
A couple of years ago I was delighted with the appearance of Scala. Then I started using it - and hating it.
She has many concepts from functional programming.
The akka framework allows
you to write reliable applications. It runs in the JVM, so it can use any library from Java, and the JVM is very well processed for speed.
The language itself is pleasant. But what stopped me? JVM. Managing jar packages is too complicated if you compare it with Rubygems and Bundler.
There are, of course, all sorts of solutions: SBT, Maven, Ivy, - but they all make me frown when I need to import someone else's library. Maybe Ruby spoiled me, but managing packages in it is one of the main reasons for my productivity.
What else bothered me about Scala was that the libraries I used were written in Java by people whose values and attitudes were very different from mine.
Create a web application on Scala in the framework of Play! It looked the same as creating a Java web application in the Play! framework, except for a slightly simpler syntax and template search capability. Although Rails was a big influence on Play !, the difference between them is intuitive.
Elixir Ecosystem
Package Management via Mix
Immersed myself in Elixir for the first time, I stumbled upon Mix. This is a hybrid of Bundler and Rake in Ruby. What I like about him so much is that he is no worse than Bundler and Rake. It is not much better, but the bar has been raised high enough and going up to it is already an achievement.
Mix does the job beautifully, doesn't get in the way, and doesn't make you mess with XML.
Erlang Virtual Machine
Elixir runs in the Erlang virtual machine, and supports almost all the values of the Erlang community. Elixir and Erlang pride themselves on focusing on functional programming that is error tolerant and scales well.
Most of the discussions on Elixir come down to the following statements:
- 50% of telecommunication companies' networks work at Erlang. When was the last time your phone had a break for “scheduled maintenance”?
- Millions of processes from WhatsApp, bought for billions of money, worked on one server, which was supported by 450 million users - and all this was managed by 32 engineers
The same values are close to the Elixir community. If you, as a developer at Elixir, use Erlang supervisors or
cowboy http server , you do not feel that you are betraying your values.
Phoenix Web Framework
Obviously, the
phoenix framework was greatly influenced by Ruby on Rails, and creating a web application for Phoenix looks very much like creating an application for Rails. I like the Rails router. As well as ActionController, ActiveRecord, Rails Views and the way you can program the application. I like the organization of applications in Rails.
Phoenix is so similar to Rails that you’ll feel as if you’re making an application for Rails, except that it will work under Elixir and have all the advantages of Elixir and the Erlang virtual machine.
In addition, it supports WebSockets through the channels. This allows you to easily use the WebSockets provided in Firebase.
Did I say that he is fast? He is fast as lightning. Take a look at the logs from my server on DigitalOcean costing $ 5 / month. Yes, yes - requests are processed in microseconds on a single-core machine.

Leadership
In my opinion, the difference between simply open source and movement lies in the leadership present in the project. In short, to improve the software every day, it is necessary that very smart people contribute to it.
Rails has gained so much momentum thanks to the work of DHH, Aaron Patterson, Jose Valim, Wycats, and lots of others. There was no such thing to launch the first version of Rails and the work got up.
This is all
an old habit of working a lot - and building a competent community
requires a lot of work . Jose Valim, Chris McCord, and all the other members of the main teams of Elixir-Lang and Phoenix have worked and continue to work for the prosperity of their community.
The Web is waiting for great transformation
Recognize - CRUD applications are a commodity today. The next startup, AirBnB for Ketchup Rental, is not likely to survive.
Win those who will accept changes in technology. The fact that in WebSockets, processes and concurrency in Phoenix and Elixir are easily achievable, and because of them you do not have to compromise the ease of programming, it just changes the whole thing.
I really love Ruby on Rails. He changed the way he created web applications in the years 2005–2014. I think that Elixir and Phoenix will produce the same effect in the years 2015–2025.
If you already want to start making web applications on Phoenix and Elixir,
here's my tutorial .