I'm a senior, worked with Ruby for a long time. There's nothing wrong with this code, it's just Ruby, using some of its new features (which all look pretty organic, style-wise). It's been obvious to me for a while: good languages have a fair balance of paradigms. While Ruby is more OOP than others (everything is an object) it also has some fairly nice functional features that are, in the context of the language, are actually fairly easy to comprehend even by junior devs.
I'm beginning to think that the true reason for Ruby losing popularity is because some find it somewhat difficult to wrap their heads around it, but I don't know why -- some people maybe have a completely different mental model and processes in their heads? For me, from day one I got my hands on the language it seemed perfectly natural. Now I program in several languages with various features and properties (compiled/interpreted, strong/weak types, procedural vs OOP vs functional) -- all I can say is it is joy to write programs in Ruby. About the only things I dislike about it are the following: 1) they could've come up with better ways to signal code-block boundaries (keyword `end` is used with way too many different constructions) and, recently, 2) Type implementation where types are declared in separate files, which is probably sub-optimal. For (2), however, I do understand why it is the way it is: they needed something that would not break an already more or less complex argument definition rules (named arguments, default values for named arguments, etc.) and also something that was a layer on top of the language and not so much part of the language itself -- so maybe it's better this way?
Btw, anyone used types in Ruby? Any tips? I'm still avoiding this, wondering if it'd be a boilerplate and a constant annoyance and waste of time. But does anyone think there is a legitimate way to use it and benefit from it in Ruby (language being interpreted and not compiled)?
My take on typing and Ruby is that it makes sense in specific parts of the code where you expect to get high benefit from it.
Overall, I don't like using types for the whole project. The reason is that you end up losing some specific Ruby benefits, like being able to express the solution in a few very concise lines of dynamically typed code. Ruby is not designed to be a type friendly language and that shows when trying to use types. It works but it doesn't feel like pure Ruby anymore. It's definitely a compromise. You lose a bit of ruby expressiveness to get some type safety.
I want to emphasise that I am actually very fond of types. For example, I've been learning Rust and I really enjoy using Rust for very different reasons than I enjoy using Ruby.
I think that tools are best used in the way they were intended to be used. And for Ruby that's without types. For Rust it's definitely with types. I enjoy both very much.
In Ruby I'll use types in cases where I would actually prefer to implement the part in another language (like Rust) but using typed Ruby is going to be more maintainable than introducing a whole new language just for one section of the code.
I'm beginning to think that the true reason for Ruby losing popularity is because some find it somewhat difficult to wrap their heads around it, but I don't know why -- some people maybe have a completely different mental model and processes in their heads? For me, from day one I got my hands on the language it seemed perfectly natural. Now I program in several languages with various features and properties (compiled/interpreted, strong/weak types, procedural vs OOP vs functional) -- all I can say is it is joy to write programs in Ruby. About the only things I dislike about it are the following: 1) they could've come up with better ways to signal code-block boundaries (keyword `end` is used with way too many different constructions) and, recently, 2) Type implementation where types are declared in separate files, which is probably sub-optimal. For (2), however, I do understand why it is the way it is: they needed something that would not break an already more or less complex argument definition rules (named arguments, default values for named arguments, etc.) and also something that was a layer on top of the language and not so much part of the language itself -- so maybe it's better this way?
Btw, anyone used types in Ruby? Any tips? I'm still avoiding this, wondering if it'd be a boilerplate and a constant annoyance and waste of time. But does anyone think there is a legitimate way to use it and benefit from it in Ruby (language being interpreted and not compiled)?