We are already packing 600 handouts for participants of
RailsClub 2017 on September 23, and our speakers add the final touches to their presentations. Today
Alexey Mogilnikov talked about Elixir with Nikita Sobolev, who makes services at wemake.services,
organizes meetings of
elixir-lang.moscow and is an ambassador for Auth0.
Tell about yourself, what are you doing?')
I am the technical director of the company wemake.services (and yes, we make services), and I also conduct conferences on Elixir (
elixir-lang.moscow ). These two aspects are related: we are a project team, we are engaged in developing projects to order, we often work with different technologies and are not afraid to try new things. At some point, we had a client who needed to develop something unique, and there were a lot of web sockets involved. We work mainly with the Python + JavaScript stack, and neither Python nor JS will support this number of sockets on an adequate number of servers and for adequate money. We began to look for what can be applied. The best performance option at the time was Clojure. But I didn’t have anything to do with her - I didn’t like the syntax, brackets, all this horror. Clojure is too different from other languages ​​that I know. I did not go. Elixir was second on my list. At that time I already met this language, I saw the documentation. I read, I decided to try it and I really liked it! We began to develop very quickly, especially considering that I did not know this language at all.
What did you like? What bribed in comparison with Python?I liked Elixir exactly as an addition to Python. Python has certain limitations: for example, GIL, poor asynchrony, etc. In terms of asynchronous programming, Elixir is a fairy tale. I really liked such chips as pattern matching and pipe. Now I try to use them in general in all languages ​​in which it is possible. This changed the way I see the perfect code as a whole. When we started to use all this, the development went very quickly, especially given the fact that we did not know this language at all. Elixir is similar to Ruby, and I don’t know Ruby at all :). The only difficulty is OTP and that is related to Erlang.
Why didn't you choose Go? Why didn't he come up?I just don't like Go and that's it. I don’t like his package manager, I don’t like his niche: it’s low level, but not quite. Very strange hack, in my opinion. We didn’t even consider it, but I know that now a lot of developers are writing on Go. And many are switching to Go with Python, due to performance gains.
What are the main advantages of Elixir?Stability of work. We have an example: for one large logistics company a tracker was written in PHP. He constantly ate an unlimited amount of resources, fell and died (the Post of Russia gives clumsy statuses, then you have to give clumsy statuses) everything constantly broke. We were engaged in the support of this service all day. And then I rewrote it on Elixir and that's it! It has been working without problems for already 9 months and consumes many times less resources.
Often, when switching to another programming language, a different paradigm, for example, a functional one, problems begin because of the difference in approaches. When going to Elixir does this happen?There are quite a few such problems. They are connected with the fact that nothing can be mutated and states cannot be stored. Sometimes you want to save some state in order to apply to it later. I always want to mutate something, do monkey patching. In Elixir this can not be done, this is solved only in one way - by processes. Save the state, create a new process and put the state there. If you want to mutate something somewhere - send a message to the process, it will change it, and not by mutation, but simply by creating a new copy of the data. In Elixir, everything is built on processes, it is a very simple and understandable concept. If you stop referring to processes as to full-fledged processes of the operating system, and to understand that it is just a small, lightweight process that can have its own internal states that can communicate with others, then this is very similar to objects in the OOP. That you create an object, that you create a process in Elixir is very similar.
What are the disadvantages of Elixir?In the first year of our work with Elixir, he did not have libraries. We wrote all by ourselves: authorization via VKontakte, a library for declining Russian names, adding recaptcha. The second problem is the number of developers, the ability to hire someone, the level of expertise. There are no elixrists at all, there are Erlangists, but they don’t really like Elixir - they love Erlang and want to write on it. Now many rubists are interested in Elixir, they want to switch to it. This is cool, but of course they will have to learn: 3-5 months (depending on the level of knowledge of other technologies) will have to be mastered, during this period you will have to be a bit blunt and write slowly. There are still certain technical problems. For example, memory starts to leak due to incorrect settings, or processes fall when they are too heavy due to the wrong architecture. If there are too many messages in the process, the message box will overflow and everything will die. It is rather a matter of architecture, proper construction. There is a good book “Erlang In Anger”, it tells about these and other problems that may
Erlang is a rather old technology, older than Python and Java. Until recently, it remained niche. Everything changed when Elixir appeared. Why didn’t there appear new languages ​​based on the Erlang virtual machine that would help this technology to become mainstream?This is due to the way the world of web development is changing: all realtime, a large number of interactions, all services are connected with each other, somehow communicate. When you have an isolated service that does not interact with others, synchronous - all this is simply not necessary. Now you can communicate with other services, do a lot of everything in real time, asynchronously, and moreover, you can bring all this to microservices. Do not rewrite everything in Erlang and Elixir, but write a small piece (as we did with that tracking), and leave the rest of the code in other languages. Under these conditions, Elixir has become a very suitable technology.
How did you get to the rubists conference?Matter of chance. I saw the conference site, wrote to the organizers. I was offered a presentation and I thought it was a great idea.
What will your report be about?About Elixir. Why Elixir is not Ruby, but better.
Why does an average rubistu come to this report?You can see new horizons. When you listen to a report on a new library in Ruby, you can deepen your knowledge in a particular technology. And if you go to the report on Elixir, you can then expand your knowledge, find out what you can do differently. Such things help you grow as a developer.
Come to the report, the conference is already on Saturday! Register
here .
Traditional thanks to companies that support RailsClub.
mkdev is the place to find and hire a personal programming mentor.
Regardless of whether you are working or just starting to learn, the mentor will help you set out your professional goals, create a personal training program, intensively transfer to the required field of development, check all your code and answer all your questions as soon as possible.
In mkdev, there are mentors with a wide variety of specializations - from web development on Django, Rails, ASP.Net, and Spring, to mobile development, system programming, DevOps, and working with big data.
See you on Saturday!