Evil Martians developer
At RailsClub 2016 he spoke about Active Cable.
We've managed to talk with Vladimir after his speech.
Please, tell us a little about yourself.
I came to Ruby not so long ago. About 4 years ago, I tried the Rails for the first time. I liked it, but the project I was working on did not use them. Therefore, I had a pause until the next reincarnation of the Teachbase, our startup. Teachbase is a SaaS system for study management, it allows you to create your own Coursera within a company or project. When I came, it was a terrible PHP project, and I hadn't a lot of experience. I was coding what they said. Then I got acquainted with the Rails and from the moment I became the CTO, I started to conceive the idea to write a new cool version of the system on advanced technology. This opportunity introduced itself in 2014, and then we completely switched to the rail stack in the part of the web application. Since then, I started to use Rails actively.
Biggest Russian Ruby on Rails event
How could you convinced the client to choose Rails?
It is very easy - I am the client myself. I am one the founders of this startup, other two of my partners hadn't enough tech skills, so they trusted me. I hope they don't regret it. The choice of technology was on me. The only question was to find the time to swap technologies. Well, and money, of course. When the time has come, we have copied everything onto the Rails, and this third (or fourth) version of the system worked quickly, clearly, everyone was happy - both we and the customers.
Is it still online?
Yes, it's still running. We brought the project to a very good state, when making a new version makes sense not for technological reasons, but rather ideological. I don't know what guys plans for now. While they are engaged in supporting this system, selling. Everything is going well, the project is alive, working.
Teachbase is a pretty big project on the Rails. And it was Rails 4.1, we haven't migrated to Rails 4.2, although we planned. A year ago, the release of the 5th rail in the fall of 2015 announced, so we decided to move to Rails 5. Everybody knows what happened next. Another year has passed, the fifth Rails have already left, but now it is probably dangerous to migrate to it. It is necessary to wait for at least 5.0.1, and better 5.1, then you can go. We relied on the release plans of the rail development team, they didn't work, so our project is still hanging on 4.1. And there are no special problems with this.
You mean that project is finished on the tech side? And you only add something new when you understand that business needs it?
Yes. There are plans to redo a large part of logic, and this is likely to be a new project on new Rails, and maybe not on Rails. We always had Erlang on our stack, since we were engaged in videoconferencing, accordingly, we needed a streaming service that would work with the RTMP protocol. It is necessary that people using flash technology (which everyone hates) can communicate in the browser, conduct webinars on a large number of people and so on. Backend for all this served as an erlang service, which budded off from a fairly well-known project Erlyvideo.
You took an open-source fork?
Yes, it was open source, version 2.18. It happened in 2011. First, we just used it, then we began to open bugs and edit them, adapt everything to our history. And then Max Lapshin "closed" the code and began to develop paid version Flussonic. It wasn't a problem for us. So we had experience in Erlang, and we started doing some other minor services for the Erlang system. Our stack has found the second main language.
It's not easy to find good Erlang developer. That only Erlangist, who we had, came as a student, he knew C and knew mathematics well, he had an olympiadic past and he wanted to work. As an Erlangist, we brought him up from scratch. By the way, he still works in this project.
But wasn't able to find more Elixir coders, so earlier this year, when I was still working for Teachbase, we started a program of acquaintance with Elixir (both for those who programmed in Ruby, and for those who programmed for Erlang). There was a separate subproject, in which there were 2 developers: the Rubist and the Erlangist. They had to learn technology together, using each of their strengths. One better knows Ruby and its paradigm, knows Rails, which are similar to Phoenix in the MVC part. And the second person who knows Erlang, can handle Elixir too. The project has not been completed yet, but it is very interesting. We began to move onto this stack, rather because of its popularity, so it was easier to hire new employees.
Maybe you would like to migrate to Phoenix? Get rid of Ruby, and install Phoenix over Elixir?
When we were thinking about the migration to Rails, there was an alternative option to switch immediately to Erlang. I was ready to do it. Probably we would have started longer, but probably it would be better in terms of efficiency. It's good that we hadn't done this: our loads doesn't require any creepy optimizations, and the Rails is quite manageable, and the development speed is much higher. Now I don't think that Phoenix can replace the Rails completely from the point of building business logic, the layer of working with data.
As far as queries are concerned, sockets (this is a separate conversation we will return to it) - with this in Phoenix everything is fine. But Active Record (or its alternatives) and the ecosystem around it is so much more convenient than anything Elixir has. It's logical, there's another paradigm, it's not so easy to make a tool that's easy to use. Therefore, in my opinion, Elixir and others, with Phoenix or without, are more likely technologies for the ideology of microservices. It is necessary to use them in some heavy part, in which many customers are "knocking" with some tasks and requests. Such parts can be written by Elixir, they can be solved by several different services. And the basic logic should, I think, remain in the Rails, if it was originally written on them. But even if I was starting the project from scratch, I would not do everything on Elixir anyway.
You talk about Teachbase and your role as CTO in it, as a past story. Now, as far as I know, you work for Evil Martians as a developer. Why did you move from management to development? More often people want to grow from developer to manager. Do you think this is a step back, or is it an intermediate stage?
First, for a long time I was in Teachbase the only developer. I started to recruit the team only in the last couple of years, when we had such an opportunity. The problem for me, as for the developer, was that I tried a lot, learned a lot, but mostly from my own experience. I've never worked in a team led by someone who was more experienced than me and had some knowledge that I didn't have. This was one of the reasons: I was bored, I realized that my own growth in Teachbase will go hard. Especially when the project stabilized, there were no super interesting tasks, only fluidity such as adding features, there was creativity.
I looked at the Martians in the first place, because I was familiar with some guys, I was on the Brainwashing course, since then I had the most pleasant feeling about this team. I really wanted to work with such people, share experiences, share my ideas. When I worked in Teachbase, I had no one to discuss any technical ideas, there were no people who would understand technical aspects. So I wanted to get into a strong team.
The fact that I had "power" in Teachbase, and now I'm an ordinary employee doesn't scare me. Probably. Although my wife says that after I stopped being a "boss", I try to manage houses a little more often. Compensate.
I like the lack of a hierarchy, you can talk to everyone calmly, argue, swear sometimes. I'm glad to be in this environment.
We've started to talk about Rails and long-awaited 5th version. For example, Action Cable, that you will discuss at the conference. What does Rails miss?
I would ask another question - what is excess in Rails.
Great question. So, what would you throw away?
The front part and assembly of assets using Sprockets, in my opinion, is an outdated scheme. The front is now being written with bundlers, there is a very developed ecosystem. This works, in my experience, much nicer than Sprockets. It's fast, convenient, lots of extra features, fine tuning and so on ... The same autoprefixer can be inserted into Sprockets. But if you add another 20 similar plug-ins, then Assets, most likely, will be assembled for a very long time.
At one time, Sprockets was a real breakthrough. Perhaps, now this technology is outdated, because the front-end is developing at crazy pace.
Because only Grunt was popular in front-end, awful and monstrous. For a long time it pushed me away from using all of this until a more pleasant alternative appeared. Let's talk about the current situation: if I've just started a new project and took Rails as a backend i would separate the development process for back-end and for front-end coders. It is very convenient from the development point of view. There is no need for a front-end coder to "lift" the server. Let him do frontal work on specification, which backend coders gave.
What technology would you use instead Rails?
It all depends on a kind of project, of course.
Let's take Teachbase as an example. API, interaction on JSON. We throw out the Action View, throw out something else. Maybe you should use alternatives of Ruby, but not Rails. Or even another language?
Good question. If the question is like "anything else on Ruby" - then no. Firstly, I do not have enough experience. I tried micro-frameworks like Cuba, Sinatra. Just experimented and watched what's happen. I'm not interested in big alternatives, such as Trailblazer or Hanami. I still do not understand why I need it. Yes, I saw benchmarks, everything is cool, fast. But the Rails and rubies are chosen not in order to be fast, but in order to be convenient. Therefore, this argument is not the most important for me.
Yes, Hanami has one very big disadvantage: no one uses it.
Exactly! It is difficult to "fight" with Rails, which everyone uses, with it many begin their journey in Ruby. The real competitors to the Rails are now not inside Ruby. It's Elixir and Phoenix, which are gaining popularity. In my opinion, this is partly because Elixir has a good PR. It is being sold to the team. Even in Russia there are people already who use a hybrid stack - part of the Rails, part of the elixir. Everyone wants to try it. And most importantly, everyone wants to sell the development on Elixir to the customer. As a commercial project, Elixir is a very cool thing. It is simpler than Erlang, although personally I would still prefer Erlang. Yes, it will be a little painful, there will be more code in places, although it can be optimized.
We started talking about Ruby alternatives. You have a lot of experience with Erlang, you wrote in PHP, as far as I know, you still write on Go. What other languages have you tried and which do you want to try?
Let's speak chronologically. In schools and university there were Pascal, C, Basic, Assembler. But at the university I missed programming, I really did not like it. I still wonder how I accidentally became a programmer. I started with ActionScript.
Is that flash?
Wait, the third ActionScript came out a long time ago, it's old. About 10 years. Is it developing at all?
Yes, he is very old, but still alive. Especially in the gaming industry, they made a lot of optimizations in terms of graphics, rendering, using GPU and so on. You can write great games using it. It seems that some of the popular online games, such as Tanks, was originally on flash. Now I do not know, maybe until now.
There was a period when these technologies were everywhere, when, for example, it was used to create all video chats, flash was everywhere. Now it is not enough. Flash used to implement what is now in the Web RTC, peer-to-peer. In the end, this project was abandoned. Initially it was called Stratus, we even did a side project on it - a portal for psychologists with the possibility of consulting online. It worked time to time. Now those webinars that work in the browser uses Web RTC, but in most cases it's not. flash, rtmp are still used for streaming.
I knew ActionScript very well, but now I wouldn't say that I'm an expert. And I do not plan to go back to it.
And now back to our question: what happened after ActionScript?
Then there was php. I don't remember what version there was, there were some issues with it.
And how did you get to know Rails?
It all happened by chance. There is such a wonderful Coursera playground. When it first appeared, there were about five courses, one of them was about SaaS development. This course, in fact, was such an introduction to Rails, then another 3. I can't say that I learned the Rails for this course. It was a very simple course, output of one page and the search from the database. But it was well told about testing, about all its levels. After that, I wrote a micro service for our system. Very scary, ugly, it was even launched through Rails s in development mode. But he worked, almost did not fall.
It's hard to say at what point I started studying and doing something. A strong impetus was the visit to Brainwashing. When I went there, I practically did not know anything about Rails. And on the course got a kick, let's just say. Sat down and began to develop.
Can you say that Ravil and Gazai had a big influence on you?
Yes, they did. If we continue to talk about languages, next was Erlang. Sometimes now I use Golang for different things. The language is quite simple, you can choose it if you need to "sketch" something quickly. It is compiled into an executable and can be used. I also did a lot of front work, now less.
You don't want to do the front-end? Go to the dark side.
Good question. Probably not. I'm not very good fronetend dev, because I'm not very strong in everything that concerns styles, layout and other things. Especially with the new muddies: some CSS modules, CSS 4, everything changes very quickly, I do not have time to follow it. I've never liked it, I always thought the layout was work for someone else.
Almost always we gave it to outsourcing. We've got a code, we integrated it.
How do you participate in open source? Are there any projects that you would like the guys to pay attention to?
Again, I've advertised Brainwashing. Open source for me started there, I made my first commit on the OS. As part of the course, the guys came across a bug in pry-byebug, which was extensible in C. I found it, fixed it, sent it and got my first pull request, got pleasure from it and got a bit hooked. I started doing this.
If we talk about other projects: I worked a lot on Rubocop, this is Bozhidar Batsov's project. I really like this project and the whole idea that the code should be stylized. I propagandize it everywhere.
But you don't use the default rubocop's configuration?
Of course, I always have something right there.
Do you have the existing settings that you always use or each time you need to negotiate with other developers in the project?
Differently. Now I, for example, came to the project with a large code base and we screwed the mandatory check by rubocop, but we had there very minimal config that checks for very bad things, such as a forgotten debug in the code or focuses in the specs and so on. And we also have several optimization cops. Things like the length of a string, the number of lines in a method, and so on, we don't check in this project.
And are you a fan of 80 characters, 120 or just turn off this check?
I support this topic, usually I put 100. This number was obtained by experience: I worked for a long time on a 21-inch iMac and developed with splitscreen. I did so that all parts of the screen included all the lines. That's about 100 characters. The logic of choosing the length of the line was such because the horizontal scroll is very inconvenient.
About the length of methods or the length of the class ... no.
The comment at the beginning of the line, enter at the end ...
I always put an empty string at the end. I do this because it's so convenient to go to the end of the file. There is some indentation from below, you do not need to get to the border of the display. I read somewhere, what historical limitations this rule was caused, in some old systems. I do not exactly remember what was there. And now the GitHab constantly highlights this in the diff, "swears" when you do not have an empty line - it's not very pleasant.
In my default config on the zero project much is included, but these parameters of complexity are a little increased. Sometimes I just disable this cop locally, and that's it. But in all the hems that I deal with, or in which I actively contributed, I introduced this matter.
What other projects should I pay attention to? Which ones did you take part in?
I worked a lot on projects from the InfluxDB ecosystem. This is a database for time series. It's an interesting project, now it's grown in InfluxData, they have their own stack. It's something like a stack from Elasticsearch, where you have a log collector, a visualizer, the base itself, but it's for some time metrics. I started using it in Teachbase, it was not very well known then, it was about a year and a half ago. Their story is very similar to the story with Rails 5: there was version 0.8, they promised to release next month, more stable and with bugfixes. It was rather risky to use a not ready story, a couple of times everything was very scary. But in the end, the promised version came out, like Rails, only at the beginning of this year. We lived a year on an unstable version, we had to work with it after all.
One of my big open source projects is known to those who worked with this database. I wrote an adapter for this database in the style of Active Record. The project is called Influxer. It is very similar to ActiveRecord: you define a certain class, tell what attributes it has (these are the attributes of these labels in the database), and it allows you to make queries, such "syntactic sugar". InfluxDB supports a SQL-like language, and instead of writing on it you can use this wrapper. It's convenient, there are some fiches, links to models and so on. It was actively used in Teachbase, for which it was done. I still continue to support it, in connection with the release of new versions of the database and the changes in API, it is more or less relevant. The project someone uses, there are several tens of stars.
In addition to Influxer, I was involved in other projects for this ecosystem. Until some time, all the code was open, the base itself and all the secondary services that were used there. This year they introduced a commercial option.
Part of the code, of course, is no longer in open source, especially as far as clustering is concerned. All the rest is open. Everything is written on Go, it was my first go experience. I did a couple of patches in a project called Telegraf: it's a log collector, something like Logstash or new beats from Elasticsearch. The project is very actively developing, to a stable version far. If you want to try go and participate in open source, know that it's pretty easy to do pull request.
Tell me more about Thinknetica. You are a mentor there, what does it mean? What kind of experience did you take from there? How many people was taught?
Yes, I like the word mentor. Earlier we called each other mentors, but it somehow is not in Russian. I have been working there for 1.5 years, but with interruptions. We take a group, we teach them, then we take a break and so on. I taught like 50 students, maybe a little more. 20 percent of them are very classy guys who have been well employed after the course. Many of the graduates are then arranged for profile positions, but I do not really follow it. When you teach fairly simple things (we do not teach anything complicated), it broadens the horizon, prevents the eyes from getting soapy. You see different code of very different people. You see different mistakes, first of all. It doesn't allow you to dry out.
Tell me about what you will report at RailsClub?
Let's go back to the spring of 2015. Some time before the conference was held, at which DHH announced this wonderful feature.
Is this really a great feature for you or such a "great feature", in quotes?
I have an ambivalent attitude towards it. In any case, this is a great feature.
In Teachbase we used websockets. Naturally, they were supported by the Erlang, because it was our stack. We had plans for tight integration of the service, which processed data from web sockets, with a rail. We had our own idea (it is implemented, laid out in open source and works), how to make Rails with sockets. And now, in March or April, Action Cable comes out. I watched the video, watched the examples. The first impression was: "Wow, wow! It's cool, it looks very cool, convenient, beautiful - just what I would like to use. " This was an additional argument to not migrate to 4.2, but wait for Rails 5 to make something new using the Cable.
I really liked how everything was done. But there was a second thought - what technology it will use? I had this thought when the repository of the cable in the source code was separately placed on the Githab. Then it worked on Celluloid, if I remember correctly. That was implemented in Ruby, which is not cool. I have an opinion that there's no need to write competitive programs by Ruby. This is not what this language was designed for, especially when it comes to scalability and efficiency.
Then I had an idea to take good from Action Cable and good from implemented in the service on Erlang. And there was already a lot of things: horizontal scalability, various authorizations and so on. Then I did not know about Phoenix yet. As it later turned out, it was very similar to Phoenix. But only done on a live Erlang. Although in fact inside all use the same Cowboy as the Erlang web server.
For the year in the cable, of course, there have been a lot of changes. All of them, perhaps, are positive. First, we got rid of Celluloid in favor of nio4r. Many different synchronization possibilities, adapters and others were added. But the basic problems didn't go away quickly. Just recently there was a sensational bug with leaking memory, non-closing connections. Oddly enough, it arose after the 5.0 release. Still hangs a few bugs related to performance. All this shows that Action Cable is not suitable for production in any large system. This is not the tool that can solve the problem.
What kind of problems can Action Cable solve?
We all know that all the innovations in Rails appear for the a single well-known project with the letter B. I checked that Action Cable is actually used there.
Or maybe it's not Action Cable at all?
Maybe. At least, the protocol of the web sockets is signed as ActionCable. The protocol is very similar. Unfortunately, there is no insider information. But I would not be surprised if there is actually some server running there that just works on the same protocol, it can communicate with the rail, although in fact for what they do, it's necessary. It literally does two scenarios: sends changes that occurred on the page (someone wrote a comment, sent a task, and so on). This is a Broadcast, the first scenario. Second which sends information to the server from the client about what the person is doing on the page. It is transmitted in encrypted form, but there is roughly the following: moved to the page or closed the tab, some activity tracking.
They have all this not very loaded?
Yes. And in this case Action Cable is enough. And on the other hand, the question arises: why is there a Rails? I see the only point that is exactly used there, it's authentication. We need to somehow confirm the right person is connected to the socket, subscribed to a specific channel and so on. Here they probably interact with the application. Everything else has little to do with business logic. I did something similar, I just had web sockets used for tracking activity. All these data weren't written to the main application. They were written in a separate system, they were already processed and then stretched out when needed. In this context, it's not very clear: do you need Action Cable there or not? Is it used or not? But if it looks like Action Cable, maybe it is it. I don't know any more real examples. And I think, there are no known projects that use Action Cable. Probably, many people want to use it, but the question is in scope. It is very good at what Rails are good - quick MVP assemble, to show someone the first version of the project. Everything is boxed, sketched realtime and works. But when business grows, and there are customers, load and so on - what to do with Action Cable? You can, in principle, produce instances, it is rendered separately, as some background Sidekiq and other side services that we have in the application. But I do not know how effective this is, as long as I have big doubts on this score.
So you would ask Matts a few questions?
Honestly, I have no questions for him. I would listen that he will answer the questions of others, usually I do so, I rarely ask myself. At the last conference, I talked with you, after a report on microservices (by Andrei Deryabin, a leading podcast). And talked a little with Claudio. Even on the last RailsClub, I learned about Crystal, it's quite interesting, I'm now following this project. I'm thinking about how to apply it somewhere, write on it some extension for Ruby, there is such an opportunity. Any bottleneck, maybe even in the project that I'm currently working on. Waiting for a free day to figure out and play around with this affair. Let's see what awaits us.
RailsClub conference on which we managed to communicate with Vladimir will take place this year in Moscow 23th of September.
Get your ticket here.