Sergey Dimitrak's Ruby Journey
00:00:02
Speaker
Welcome to the Thoughtful Edge podcast. And today we have Sergey Dimitrak is our guest and we are going to talk about Ruby on Rails. Sergey dedicated almost all his professional career to the software architecture and learning how to make software better, how to make it more efficient and how to build systems. Now he works at Narver and
00:00:27
Speaker
Like, as I mentioned today, how today's topic is Ruby on Rails. So, Sergi, could you please share with us your journey as the software architect and how you came to specialize in Ruby? Yeah, hi, Nitro. It is my pleasure to be on your podcast. And yeah, as you said, like I was like whole my entire professional life. I was either like working with Ruby, attached to Ruby, but it was always like on my path. And I really love Ruby, Ruby on Rails, all the technology around this.
00:00:57
Speaker
And it was like always a dedication to Ruby. While I was not starting immediately from the Ruby, I had been with other languages for a long time before I started with Ruby. But my passion for Ruby is still like till these days is really big.
Ruby's Versatility Across Domains
00:01:12
Speaker
And yeah, I started actually programming from 1999, actually. And I started with like basic Pascal, like C, C++, build of Delphi, like all these languages. And I continue my passion going to different like
00:01:28
Speaker
for example and take participation compete with different really great mature guys and then I continue in my like high education in my institute and it was like computer science and again like I was there not knowing about Ruby even exist of that but I was already like programming on C sharp and Java
00:01:47
Speaker
And when I was around like my end of my higher years in university and about to be graded, I was introduced to Ruby and Ruby on this technology. And I just give it a try. And believe me, it was really great. I already like have some concept in my mind about like C sharp and Java C. And I was able to move all my ideas already like develop solution to Ruby with such an ease and breeze in my mind.
00:02:16
Speaker
And it was really like a breeze of fresh air for me at that time. And I continue growing in that. Then I started to work on some projects to get Ruby on Rails. It was like automation. It was another project on IoT, which we also use Ruby. Then it's like web development, a SaaS solution, PaaS solution, and everywhere we were using Ruby on Rails.
00:02:41
Speaker
Historically, I was all the time dedicated to application security department, and I was always in AppSec domain and a little bit in the healthcare, and right now I'm in retail. But Ruby fits well in all these areas. And this is great because you mature, your experience mature, and language is also mature with you, and it always has something to offer to you on each and every of these stages.
00:03:07
Speaker
And again, it's not about only like building something, but moving fast with some ideas and be able to prototype really well. And this is like where Ruby on Rails is shine.
Mentoring and Technical Interviews in Ruby
00:03:19
Speaker
It really like shines really well there. And it's also about teaching others, mentoring others. And I would say that I have never been tired of Ruby and it's still like give me something each and every day, even till now to learn and still inspires me. And this is like really great.
00:03:36
Speaker
It's worth mentioning that I have been also doing a lot of, in my professional career, a lot of mentoring and also providing technical interview and et cetera. But the vital part of being there with Ruby and providing this coaching and interviewing is also to be on both sides. So before I have been evaluating other people's, I have been evaluated. And this is also great. And I always like changing the sides. First, I was being like a validity and then I was a validator.
00:04:04
Speaker
And it's all about talking to the people, talking to the passionate people about the same technology that you love. And this is really great because this synergy of sharing experience and getting something for myself, it's always
Ruby and Cloud Technologies
00:04:17
Speaker
great. And again, it's a really huge community of inspired people. And Ruby on Rails is all about communicating and always finding something new. So either it's like SaaS, PaaS, or cloud technology. And by that, it doesn't matter. Ruby fits everywhere really well.
00:04:34
Speaker
Awesome, that sounds so inspiring and I feel that you love the language so much and considering that you had an opportunity to compare that with other different platforms like Java, I worked with Java throughout the whole my career, I loved the language but I also would agree with you.
00:04:54
Speaker
The programming language is just a tool, and we're just here to select the best tool out there, and we don't need to confine us to someone-like experience and just to someone tool. But if you like Ruby, this is great. And as Ruby's creator, Ikira Matsumoto aimed to make programmers happy. Apparently, they made happy yourself.
00:05:20
Speaker
So, like you already mentioned that it is convenient and how does it make you happy? Or does it?
Prototyping with Ruby
00:05:28
Speaker
Yeah, I believe this is a really broad topic, even maybe dedicated to another discussion. But just to mention, I feel like it's really inspiring. Why it's making people happy? Because you can start with small, with some small, really small things. And then if you'd like to go in some advanced technique, it allows you to do this. And it's always about thinking about
00:05:59
Speaker
How much you would like to put in learning some language and how much you are going to get or how quick you can start doing producing something meaningful. And this again, like when Ruby and particular Ruby and res framework is really shines because from starting like idea to start like prototyping and to bring some idea to really work in solutions, it just can be like hours, hours of doing something.
00:06:23
Speaker
already making some mocks and et cetera and already see the visual results of your work. And again, Ruby on Rails and Ruby, it's not only about like one framework, but it's like synergy and consistency along different technologies around this. So for example, you have like a problem with background workers, right? You can use like Redis or Sidekick.
00:06:43
Speaker
you would like to go to the cloud. Okay, that's not a problem. GCP allows like cloud tasks, which is substitution to background workers. So all these tools already there, and there are a lot of like mature open source tools that are either supported by one developer or group of maintainers. And they are just there and you just can go experiment, use them. And again, as I said, like you will like it. Experience is really great.
00:07:10
Speaker
Awesome. That tells a lot about how we can leverage that just not to produce something, but make us feel better while using this tool and while using that approach and while using everything what Ruby has to offer.
Integrating AI with Ruby
00:07:32
Speaker
By the way, did you have a chance to try chat GPT with Ruby? Definitely.
00:07:40
Speaker
Yeah, as you said, it's really amazing because right now everyone is, it's like on the hype, everyone is thinking thoroughly about how OpenAI chat DPG is going to influence our work.
00:07:56
Speaker
And again, for Ruby, there's already solutions, and it's called Ruby OpenAI. There's already a gem. A gem is like a library, as for example, in Python, right? It's a gem library in Ruby that can help you to solve some particular, either small or big problem, or can be used as an injection of plugin. It can be just bringing some mission functionality or some validation. Because there are so many... The great thing about Ruby is that there are so many
00:08:25
Speaker
ways you can solve the problem. There's not only one solution, but there are multiple. And a great thing on top of that is that you can always refactor and re-introduce some idea or refactor, make it better, make it concise, faster, more problem solving. And it's all there already incorporated in the Ruby idea. And again, we're going to probably talk about conventions over configurations idea. And this is like one of the part of the key thing in Ruby.
00:08:52
Speaker
But yeah, I was able to try it. Experience is not so bad. It's, again, tools are evolving. Everything is evolving, and Ruby is evolving. This is really great. There are already a few other, like, gems that are written around this OpenAI and, for example, Image Generation Dali. I was able to play around with Ruby OpenAI, and this is, like, this is really great.
00:09:15
Speaker
Wow, that's impressive. Yeah, cool. And yeah, the technology is evolving so fast and we cannot even like keep up with all of the news that just keep coming, keep coming and all of those news about new startups and new applications of the AI. It's just...
00:09:37
Speaker
insane and coming back to that one more addition if i can like for example it's only about the chat gpt right because it's always like something great tool is emerges right and other like companies try to compete right and for example chat gpt and we have another like google part which is also not so bad and it's like
00:09:55
Speaker
let's say, try to build the competitor for chat GPT, and there is also Microsoft Bing, which is also getting really good results there, competing with chat GPT. All these tools, sometimes they are creating really great ideas, software tools, etc. But sometimes they can also create really confused information or false information. But they're doing this in such a convenient and comprehensive way,
00:10:23
Speaker
that sometimes you just have to put some human and to validate those results of these tools and what they are really producing.
00:10:32
Speaker
Another thing that I also love with this like new tools is that it's not bad. It's not bad that something is like evolving because all these tools then already try to evolve already existed tools. So all other tools just set in new higher standards and they just try to compete. But in these competitions, great ideas and great solutions are to be raised and this is great.
00:10:57
Speaker
Right, right. Right now, every one is trying to incorporate some of the achievements that Charged GPT is proposing. I've recently seen a presentation by the company which is making a Capilot product. This is the tool which is so awesome and so amazing.
00:11:18
Speaker
simplifies the life of the developer significantly. It can just write whatever code just in line in your code editor, in your IDE. It can write unit tests for you. It can generate some boilerplate code or whatever else. Or take on some of the boring tasks.
00:11:44
Speaker
just, yeah, just so impressive and inspiring as well at the same time. So you mentioned one of the Rubies philosophy points, which is convention over configuration. Could you please talk about that as well?
Convention Over Configuration in Ruby
00:12:00
Speaker
Yeah, um, this is really powerful concept because, uh, there are already like, uh, let's say Ruby way or let's say rails way of doing some things. You can do it on your own, but there are some really like best practices or rule of thumbs that already developed by the community. And if you're going to follow those, then you will be gratitude in the end and you will be rewarded with a clean code.
00:12:27
Speaker
a really great code that can be refactored, easy to read code, etc. This is all about conventions or configurations. So, if you follow the conventions, then in the end you will get some really structured, not fragile but flexible code.
00:12:43
Speaker
This is all about. And there are also, as well as solutions, but solutions is always sometimes like coming with their patterns and anti-patterns. So there are a lot of anti-patterns coming from different other languages that can be really mixed into Ruby and Ruby already developed some solutions how to mitigate these anti-patterns.
00:13:04
Speaker
For example, there is anti-pattern like got object class or fat model, fat controller. How you're going to deal with fat controller, of course, you're going to make this controller skinny and move the logic to the model. But then you apply one pattern and make the controller skinny, but then create another anti-pattern fat model. How you're going to refactor fat model, of course, you're going to make the model skinny and you're going to extract this business logic to services.
00:13:33
Speaker
But services can blow that really fast with the code, and how you're going to deal with that? You're going to create the pure row, which is like a acronym for pure Ruby objects. Why? Because it's easier to test them, and it's easier to replace them, and it's easier to make a dependency injection, right?
00:13:49
Speaker
And when we're talking about dependency injection and dependency inversion, by the way, we are talking about some principles. And we are calling these principles solid principles, which are created by Robert C. Martin, another great guy who just extracted those principles and put them. And we have like solid principles. It's like syndrome, open clause principle, list constitution principle, interface aggregation principle, and dependency inversion principle.
00:14:17
Speaker
And if you follow the best practices or those principles in the end, you will not by default, of course, nothing comes like for free. You have to work, you have to like to build your solution and nothing comes for free. But if you're going to spend that much time to understand the principles, understand the other patterns, apply best solutions, then in the end, you will be rewarded with the great code that everyone would love to work with. And again, like if you can
00:14:47
Speaker
easily refactor and everything is covered with the tests, then you can move fast, which is really important in our market. Moving fast is really important and it's all coming to the benefits and joy in the end, like return of investments.
00:15:05
Speaker
Right, right, and the maintenance of that code is less costly, will require less effort to do that or to fix bugs or find bugs or whatever.
00:15:21
Speaker
Everything is moving so fast. Will the new developers come and will love to work with the code? Are your dependencies up to date? Are they covered with the test? There are so many tools developed over the time for the Ruby and Rails for different style guides and practices. For example, RuboCop, SandiMatter, like Ruby Critique, you name it, right? A lot of different tools and libraries that helps to emphasize the great practices of the code.
00:15:50
Speaker
This is also great because it's all community supported. And if you know these things, if you support this, you can contribute back. You get something from community, you give back something to community. Everyone benefits. This is like a synergy of like great people, great talent, using the great tools like Ruby and Ruby. I definitely love this approach and I definitely love Ruby already.
00:16:15
Speaker
Like if it allows you to do all that exciting stuff because myself as a developer, I totally understand everything what you're talking about and all those pains of like a structured code, like God objects or like some other anti patterns. It is so painful to deal with them.
00:16:35
Speaker
It is very good to have all those kind of card rails around the code from the very beginning around your application that will allow you to just don't make the mistakes that are so widespread.
00:16:51
Speaker
if there are some framework that will just mitigate them and will allow you to write a better code from the very beginning, it's just amazing. And speaking on that, can you discuss some of the other key trends and weaknesses of the Ruby in comparison to other platforms and languages, for example Java or Python?
00:17:16
Speaker
Again, this is another broad topic, but I will be able to at least emphasize a few.
Concurrency and Parallelism in Ruby
00:17:22
Speaker
Of course, if at least one language will be ideal, then there will be no other languages. But in reality, nothing is ideal. Each and every tool is good for some particular problem-solving solution.
00:17:36
Speaker
in talking about Ruby and Rails, et cetera, it's really almost ideal everywhere, but there are some key cons that I can mention, and the biggest probably, the main problem, it was from the very beginning, is the problem of parallelism. We're always talking, when we're talking about classical Ruby implementation, like C implementation, because Ruby is implemented on the C, and it's called
00:18:00
Speaker
mass implementation, classical Ruby implementation. It's a lack of parallelism, right? And we're always talking about concurrency versus parallelism. And in Ruby, there is no parallelism, but there is concurrency. And it was even from the version of Ruby 1.8 when we have green threads, green threads which were spanning themselves and then held themselves to be able to delegate some work to other threads which were sleeping before.
00:18:28
Speaker
And then there was a huge improvement in Ruby 1.9 where the new version of the Ruby virtual machine was introduced. And instead of green threads, there was like this threads which spun by virtual machines. It was a great improvement. And then there was like Ruby 2 version and even more improvements in the speed equality and Ruby 2.5 where there is like pattern matching and all this kind of great things. And right now,
00:18:56
Speaker
It's even better because right now with WebAssembly, there's like Ruby, which can be run in the web browser in the newest version of Ruby. And JIT, like just in time compilation for the Ruby. It's also there. I mean, the language is evolving. There are some demands of the current like problem, et cetera. And Ruby language is not fragile. It's flexible. It's evolving. And it's just evolving to solve even more problems, not to sacrifice the previously already working features of the Ruby language.
00:19:26
Speaker
But parallelism is one of the problems of Ruby. Because if we're talking about parallelism, it's not possible because there is a special global interpreter lock, put it in the Ruby, specifically in the Ruby root machine, so that only one thread at a time can actually handle the context of execution. Everyone else is actually halting. But that is done for the reason. There is actually a good explanation about that. There are actually a book written about that.
00:19:54
Speaker
It's done with the thinking of the C extension. And there are a lot of different libraries, like, for example, Nokogiri or FF5, which are using the C extension. And if we are going to a lot of parallelism and there will be a multi-thread environment in C extension, that will be absolutely hard to track this
00:20:15
Speaker
problem in C++ or C extension. And if it will fail there, then it will fail the whole process of Ruby because Ruby is based on the C. So with the thinking of this extension, there is like a global interpreter lock, which doesn't allow us to use the full parallelism. But there is like a thing of concurrency.
00:20:36
Speaker
And if you think about this problem, you sometimes don't even need this parallelism, because there are already other techniques available to omit this problem with parallelism. And for example, just use multiple processes of the Ruby, like Puma, for example, Puma application, etc. What it's doing is just like spun different workers in different processes, which is a loft. It's just like more memory on the footprint for each new process, but it emits the problem of parallelism and you just get it.
00:21:06
Speaker
Or there is another implementation of the Ruby like gRuby, which is already running on Java virtual machine instructions and it can actually use the parallelism.
00:21:15
Speaker
Again, in modern society, we don't even need this parallelism, and this problem is not that big while it exists because there are some tools which just simplify you dealing with parallelism. Also, another thing is, and I believe it's not even a cons but actually a pros, comparing to Python and Java, Ruby is really a highly dynamic language. It means everything in Ruby is just object-like.
00:21:43
Speaker
Boovings are objects, right? Numbers are objects, like objects are objects, classes are objects, like, because in under the hood, like... So there are no primitive types, right? Yeah, because the only primitive type is the structure of type value, which is like a C. So each and every primitive is described by C structure with a type value. And again, it's great because it's moving us to... It's great because it allows us to develop the C extension with ease.
00:22:10
Speaker
And again, it's another topic for discussion, but if you once would like to develop C extension for Ruby, it's really a great opportunity to just see along and it's really, experience is really great if you'd like to do it.
00:22:27
Speaker
Yeah, interesting, interesting. Now, looking at Java, I see that there are a lot of similarities as well. Maybe in some languages, some of the items are handled better. In some languages, it's a bit worse, but still, as you mentioned, as we can use parallelism, as we can use multicore,
00:22:51
Speaker
like approaches to run different threads on different cores on the modern CPUs. Yeah, that might not be a big deal actually. Exactly. And could you please also talk about the challenging projects were used Ruby and what were the difficulties that Ruby helped you to overcome?
Managing Complex Projects with Ruby
00:23:13
Speaker
Okay, that's a great question because surprisingly and historically, all my projects were changing. So there was no easy project. But that's a great part of that. Because with Ruby, I can solve like, different ways the same problem. And I can go like back in time and refactor something and apply some different ideas and thoughts. And Ruby just allowed me to do that. And for example,
00:23:37
Speaker
One of the project we have to use like a lot of like services and there was like a really context sharing between those services and it was really like a definition or like business goal from the clients to make this really fast, straightforward and easy to maintain and changeable because it was using like a lot of rest and it was like using like API different versions and there should be communicating using other microservices in Python and Node.js
00:24:06
Speaker
And we decided to go with another great pattern, which is called Interactor for the services. And you just abstract all this like common execution in particular Interactors. And for example, if you need to send some letter, you have another Interactor to send it. If you need to decorate, you have another like Interactor to decorate something. If you need to process some gRPC, for example, protocol,
00:24:30
Speaker
That's there. You just create another interactor. And then interactors are chained into organizers. So you create one organizer that shares the contact and organize those interactors in one chain. And this chain, of course, like called like chain of visibility as like another design pattern.
00:24:48
Speaker
And then you're just orchestrating the group of these organizers and call them separately in parallel. And the execution takes a really fast time because the execution of those group of organizers and interpreters are just paralyzed and separated and not affecting each other. So some sort of automatic and
00:25:15
Speaker
like really atomic operations ideas is like solved with this organizers and instructors and it even goes so much great because it evolves in separate service, separate API that was like extracted as a separate product later on and we have to support and extend it to really like
00:25:35
Speaker
other approaches and other like business goals and we just benefit from writing the clean code from the very beginning and while architecting this like interactive approach it was really easy to go with different version on one version and which is like multi-version approach and again we benefit this because we were able to
00:26:03
Speaker
come back with non-breaking changes for different clients. Yeah, that's very flexible, this schema that you described and the way that you decided to use those interactors and how you described the orchestration of that. Sounds like very flexible approach, which gives you a lot of capabilities and you can combine them in different ways.
00:26:30
Speaker
achieve whatever results you need. Very good. Moving forward and talking about the future of Ruby language, especially with the rise of other languages and platforms like Rust and Go that might be perceived as competitors.
Ruby’s Evolution and Cross-Language Influence
00:26:56
Speaker
How the future of Ruby will look like?
00:26:59
Speaker
Okay, I would say that the future of Ruby is great and is greater than ever. I know that there are like each and every year, like in 2018, for example, there was like topics or videos like is the Ruby that in 2018? And then is the Ruby that in 2020? And is Ruby that in 2023? It's not that.
00:27:20
Speaker
It's absolutely not that, it's evolving, evolving together with all the communities, all the other languages. The great part of that is that a lot of those languages are actually inspired by Ruby. For example, if you're talking about CoffeeScript, CoffeeScript was really adopted early days in Ruby and it was used as a substitution of better JavaScript.
00:27:43
Speaker
And then the JavaScript EconScript 2015 came and a lot of features in new EconScript and that was taken from CoffeeScript, right? And it was like inspired by CoffeeScript, inspired by the Ruby approach. And right now all this like go routines, right? For example,
00:28:03
Speaker
Some of the ideas were taken from Ruby, but right now, Ruby is taking ideas from other languages and adopt them and create even better and brighter features in the Ruby. And if we're talking about compression, it's a really great thing to compare Ruby to Elixir, because at the time when there was Ruby and Jaseva Lim, the creator of Elixir, just came up with an idea, let's create a better Ruby,
00:28:27
Speaker
He was trying to create another Ruby version but then he created a Elixir and a lot of really great core concepts of Elixir were actually inspired by Ruby. He was taking because he was like a core contributor to Ruby and then he created Elixir. And he said like the Ruby version 3 is not a Ruby but rather take a look at Elixir. This is like your next Ruby.
00:28:50
Speaker
And time flies, and some of the ideas from Elixir were migrated back to Ruby. And newer version of Ruby has some ideas from other languages. So it's not its competition, but it's competition where everyone wins. And the same like Rust and Go, inspired by Ruby, and some features are inspired by Ruby. So everyone wins, and it's synergy of all these languages, and they're still evolving. Everything is evolving. I love the passion of David Henneman Hansen.
00:29:19
Speaker
like creator of Ruby on Rails. He is like creating a blog almost like each and every day he is posting some really great ideas and we can see how in Ruby on Rails like the injection of the JavaScript really evolved and previously there was like webpack for like React.js and VGS right then there was like webpacker and right now then it was like removed with other tools and the recent Ruby and Ruby on Rails has this
00:29:49
Speaker
import maps feature, which integrates the React even in better approach. It's even smoothly. I can introduce from CDN any library, even React, and just use import maps, and it just works out of the box. No need to have a pack of a packer.
00:30:09
Speaker
So right now, it's never been so great time as right now to start Ruby. Just try it out. It's really great experience. Believe me, experience will be really great. Bright future. I like your reference about how many people like always saying that, oh, this is the last year of Ruby.
00:30:31
Speaker
And the next year is the same, and a couple of years later, they're telling the same. This is the last year, probably. I've heard the same for Java way, for the last 20 years. I hear that every year, something is coming out and saying, Java is dying, right? Java is dying. Learn something new, go outside, and just forget about it. This is the extreme technology, and it wouldn't be there anymore.
00:30:59
Speaker
And just to emphasize that it's not dying, it's like it's just another circle of evolution, let's say. Because if we can take a look at the how many companies were actually like starting with Ruby and Rails, of course, later than move to some other technologies. But as I said, starting with Ruby and Rails is really great. You can bring your ideas to the prototype to the worker solution really fast. And for example, slide share, Airbnb, Crunchbase,
00:31:23
Speaker
like Dribble, Instacart, Shopify, GitHub, GitLab, Twitter was initially written on Ruby on Rails, then it switched to Java because it has some scaling problems, etc. But again, it was easier to start with Ruby on Rails and continue and your experience is growing, your company or your product is growing.
00:31:43
Speaker
And Ruby and Rails on each and every stage of the project still can offer something and you will like it. And the biggest thing that I love about Ruby and Ruby and less is that I'm never tired of Ruby and Rails. I never think that, okay, I'm done with that, I would like to see something else.
00:32:02
Speaker
I always can learn something new and even though after this past experience like many many years of me like doing with Ruby on Rails I still found something I can learn experiment and I can like see something bright in Ruby on Rails and it's more greater things yet to come. Well that's great and as we are moving closer to the end of today's discussion and
00:32:31
Speaker
I have another question for you, probably the last one.
Advice for New Ruby Developers
00:32:33
Speaker
What advice would you give to a developer who is considering learning Ruby as their first language? Great question. And I believe that the main advice for the newcomers like Ruby, just don't overthink about it. Just try it out. Just give it a try. Try it. And again, you will like it. Believe me, the experience will be really great.
00:32:59
Speaker
Okay. Yeah, great advice. I like it. And especially how you described all the advantages of Ruby and all of the benefits that it has. Just worth giving it a try, for sure. Yep. Okay. Thank you, Sergey, for today's fruitful and interesting conversation and
00:33:21
Speaker
Have a good day. Bye. Yeah. Thank you. It was pleasure to talk to you and hope for more such podcasts.