DEV Community

Cover image for Why do you love Ruby, actually? An ode.
Sylwia Vargas
Sylwia Vargas

Posted on • Updated on

Why do you love Ruby, actually? An ode.

tl;dr ✨ I love Ruby and I'm curious to learn what makes it special to YOU (and if/what other languages you know to see what your point of comparison is)


I had a chat last week with a very kind friend who’s been in tech for quite a few years now. We both agreed we wouldn't be sad if PHP disappeared overnight and we also had no wish to come anywhere near .NET. We talked about our languages of choice and when I mentioned Ruby, he responded that he feels “meh” about it! He “just doesn’t understand what the Ruby phenomenon is about” 😩

Now, you need to know that I don't usually engage in debates like "which language is the most superior", "why VSCode is/not great" or "why you should/not use vim" because I am too much of a 1xEngineer. I didn’t think I had strong opinions on others’ programming language preferences. Why, then, was I so shocked to learn that he was mildly disinterested in my most beloved language? And why is Ruby my most beloved language to begin with?

I asked my friends why they love Ruby and also thought about it for a bit myself. I'm dividing this post in two main parts:


When chatting with friends and students, I noticed a few prevailing themes which I’m presenting below.

✨ the wealth of built-in methods

Ruby seems to have a method for every occasion and many aliases constantly joining that party. For instance, each is the basic enumerable method but there's also each_with_index. There's a size method for arrays but if you have an experience with another language and length and count seem more intuitive, please don't stress: the former is an alias and the latter is more versatile but also works on arrays.

Here's a quote from Yukihiro "Matz" Matsumoto, the creator of Ruby, that explains the design principle behind making Ruby so intuitive and seemingly "simple":

Make Ruby natural, not simple, in a way that mirrors life. (...) Ruby is simple in appearance, but is very complex inside, just like our human body.

-- Yukihiro "Matz" Matsumoto in Ruby Docs

If I were a 10xEngineer, I'd go out of my way to prove that Ruby is the best by making pointless comparisons to another language (JavaScript, for instance, which is always an easy target), just like this:

  • last in Ruby vs .slice(-1) in JS
  • .shuffle in Ruby vs in JS:
  • each_slice in Ruby vs in JS

I, however, trust that awesomeness of the gifts Ruby showers us with will speak for itself.


✨ the readable syntax

While other languages require you to explicitly write () or {}, in Ruby you can either skip them or choose more visually-pleasing solutions. For instance, you can write:

  • Person.new or Person.new();
  • Person.new("Sylwia", "Rubyist") or Person.new "Sylwia", "Rubyist";
  • or, in Rails: has_many :friends, through: :discussions, or has_many(:friends,{through: :discussions}).

Of course, there's the friendly style guide that hints at which syntax is the most readable but that is a result of a community agreement and not a rule imposed on everyone by default.

But there's more to Ruby's awesome syntax: you don't need to be proficient in it (or, in English for that matter) to know what's happening here:

5.times do 
  puts "Ruby is great."
end
Enter fullscreen mode Exit fullscreen mode

vs in JavaScript:

for (let counter = 1; counter <= 5; counter++) {
 console.log("This could be better.");
}
Enter fullscreen mode Exit fullscreen mode

Ruby looks and reads like English, decreasing the cognitive load on a very tired person who's working long hours under time pressure or who experiences occasional anxiety. This straightforward syntax is also a reason why Ruby is pleasant-ish to debug, which leads us to the next point...


✨ error messages that are actually helpful

When dealing with errors, Ruby gives you the whole traceback and a helpful suggestion when there’s a chance of a typo:
irb showing a traceback of a "NameError:undefined local variable or method 'arr' for main:Object" followed by a suggestion: "Did you mean?  array"
Believe me, these helpful suggestions have saved me so many times.


✨ the effortlessness of monkey-patching

If Ruby were a human, it would be a trusting person treating you like an adult who knows what you are doing. Case in point: monkey-patching of classes and methods. Just tell Ruby what you want to see happen.

note: This is also doable in other languages like Go or JS but it takes more effort.

There are no limits to what can be overwritten. For instance, I could overwrite the ! unary operator that returns the boolean value opposite to that of the self. In case of strings, which in Ruby are always truthy, it would always return false:

 !'Hello!'
 # => false
 !''
 # => false
Enter fullscreen mode Exit fullscreen mode

So now imagine a dystopian scenario, in which someone is blindly in love with Ruby and is a person with slightly authoritarian tendencies. In such a world, negating the awesomeness of Ruby would just not be possible. They could first define a punishment in the form of an instantly-dreaded Falsehood Error:

class FalsehoodError < StandardError  
  def initialize(object)
    message = "Cannot be negated: '#{object}.'"
    super(message)
  end
end
Enter fullscreen mode Exit fullscreen mode

And then throw it onto folks who dare to call the ! method onto a string containing the ultimate truth about Ruby:

class String

  def !@
    raise FalsehoodError, self if self == "Ruby is the most awesome language in the world"
    false 
  end
end
Enter fullscreen mode Exit fullscreen mode

You could extend it further by also overwriting the !! message so it checks for the reverse of these statements (only Ruby should be perceived as the most awesome language) but even now, if someone promoted Ruby heresies, they'd be reminded of the one true stance:
irb window showing "true" for the expression "!JavaScript is the most awesome language in the world" and throwing a FalsehoodError for "!Ruby is the most awesome language in the world"

Of course, this could be devastating in results because the bang-based unary operators pertain to the datatype and not the value of the object and this could mess up our app logic. However, it’s a good example that Ruby trusts you and gives you tools to do whatever you wish, even if the wish is to learn from mistakes.


✨ the whole ecosystem and community

Ruby seems to have a gem for everything and there are also similarly friendly, straightforward and well-documented libraries like Rails, Sinatra, or Hanami.

Funny enough, as I was writing this post, I noticed that Ben Greenberg and Paul Ardeleanu discussed the day prior why Ruby rocks during the Vonage twitch Ruby mini-series. The wealth of the ecosystem was one of the main points they mentioned. They referred the delightful Ruby books like "Why's poignant guide to Ruby", which in turn reminded me of other lovely Ruby publications such as "99 Bottles of OOP" by Sandi Metz and or "Confident Ruby" by Avdi Grimm. Even though these are programming books, you read them with pleasure (Avdi's book is especially great for the geeks and sci-fi aficionados). The joy of coding in Ruby emanates through these books.

At some point, Ben asked whether this amazing ecosystem extends to the community as well. Thinking about this made me realize that in trying to "defend" Ruby, I was completely missing the point of why I love Ruby so much. This also coincided with a lovely message from my friend Michelle Nguyen about the inclusive aspect of how Ruby was designed.


My main reason: Ruby is all in for inclusion

Before switching my career to tech, I was a human rights advocate in Poland, a linguist and a researcher pursuing my PhD in sociology of nation. In other words, I care deeply about what makes some people belong and how we exclude others on a social, economic, or linguistic level. I bring this lens everywhere, and the tech world is no exception.

Learning to code is difficult in and of itself. Imagine learning to code in a foreign language while holding a full-time job and having very little financial security. That was me after I migrated to the US. Needless to say, I was stressed. I think of myself as a fast learner, especially when it comes to language-like systems, but my initial attempts to learn python or JavaScript were short-lived and unsuccessful. When trying to decide if a career is for you, one takes every failure or obstacle as a testament to that they're not fit for it. Same was with me: I could not make sense of all these brackets and of the unclear method names (splice?) -- and the error messages told me nothing.

I imagine that if you learned Math in English, some programming concepts make more sense. I was totally swept off my feet when I discovered that variable and constant are the same as the Math concepts I know "in Polish". However, because I didn't know/need this terminology in English and in my mind "Math" and "programming" occupied completely different domains, it took me two years to put these pieces together. It would have been much easier to understand JS fundamentals.

But then, I stumbled upon Ruby and while I was still confused at times, I was never completely lost. It felt like Ruby had my back. I cherish the fact that it reads like English, that it requires minimal cognitive load, that it offers helpful suggestions when you just made a typo. I think that the convention over configuration and the strong preference for SOLID make the code more intuitive and organized.

And all this is not a coincidence -- Ruby was designed this way.

I wanted to minimize my frustration during programming, so I want to minimize my effort in programming. That was my primary goal in designing Ruby. I want to have fun in programming myself. After releasing Ruby and many people around the world got to know Ruby, they said they feel the way I feel. They came up with the phrase the principle of least surprise.

-- Yukihiro "Matz" Matsumoto in Philosophy of Ruby, A Conversation with Yukihiro Matsumoto

Ruby cherishes kindness and that also extends to its community, which embraces the acronym MINASWAN, which stands for 'Matz is nice and so we are nice". I mean, can it be a coincidence that some of the most wholesome people on tech twitter like Ben Greenberg, Ben Halpern, Michelle Nguyen or Yechiel Kalmenson are Rubyists? Or, that Ruby on Rails Link is such a lovely slack community?

I do think that kind communities attract kind folks so perhaps that’s the key to my story: I assumed that the friend, being the kind person that he is and having been exposed to Ruby, would love the language. His mild disinterest came as a surprise because he’s been so far the first friendly person seemingly immune to Ruby’s charms.

tl;dr: Both Ruby and its community are thoughtful and caring and that's why I feel so strongly that everyone should 💖 LOVE 💖 it.


Photo by Chevanon Photography from Pexels

Latest comments (78)

Collapse
 
nauman profile image
Nauman Tariq

Thank you for mentioning the Rails slack community :), glad you like it!

Collapse
 
lepinekong profile image
lepinekong

Would like to learn Ruby as it seems close philosophically to rebol/red but more mainstream dev.to/lepinekong/red-for-hopeless...
but lack of time :(

Collapse
 
sylwiavargas profile image
Sylwia Vargas

Ohhhh this is so interesting, thank you for sharing!
If you ever have a little bit of time, I’m happy to point you to resources to learn Ruby!

Collapse
 
lepinekong profile image
lepinekong

I intend to go back to Cambodia because of my mother getting very old and I wanna learn Ruby-on-rails because it seems very popular in Asia ;) Hope to start learning it next year more reallistically.

Collapse
 
lepinekong profile image
lepinekong

You're welcome ;)

Collapse
 
rsmithlal profile image
Robert Smith • Edited

The kindness of the Ruby community is one of the reasons that I have grown to love Ruby so much! The whole experience of programming in Ruby is much more enjoyable for me than Python or JS (which I also use regularly for my job).

I personally find that the Ruby language and Rails ecosystem are more in line with how my neurodiverse brain naturally thinks and solves problems. It's really interesting that you mention the easy of use and low cognitive burden as a big plus for Ruby. I have ADHD, and I never considered that this might be one of the reasons why it feels so much easier for me to express myself using Ruby than other languages. There is less to get in my way when I'm exploring concepts and working through problems!

Collapse
 
sylwiavargas profile image
Sylwia Vargas

Thank you for this comment. Whenever I'm in a teaching role, I try to always acknowledge how different folks have different learning styles and learn at a different pace — or, I'm trying to design assessments in a way that would not disfavor neurodiverse or just anxious/tired folks. Accessibility (broadly-understood) is something I care deeply about. However, I never thought about that Ruby with its strong preference for convention over configuration and friendly methods actually also helps folks succeed 💖 yet another reason to love this language ✨

Collapse
 
macnick profile image
Nick Haralampopoulos

I like Ruby for the same reasons but I have to admit: I absolutely love JavaScript.

Collapse
 
sylwiavargas profile image
Sylwia Vargas

Plot twist: I also love JS ❤️ for different reasons than Ruby and it’s a different kind of admiration.

Collapse
 
jafuentest profile image
Juan A. Fuentest Torcat

The syntax. It's so beautiful... I've used many languages over the years and none is easier to read than Ruby, that's just so important when you have to debug other people's code. I started learning Ruby because of college project using Rails like 10 years ago and it's been my preferred framework for web apps and APIs.

Collapse
 
sylwiavargas profile image
Sylwia Vargas

Wow! If only I came across rails 10 years ago! I’m happy that you got a decade of kindness ✨
Thank you for this wholesome message

Collapse
 
jasoki profile image
Jason Kim

Readable syntax and helpful error messages help me a lot

Collapse
 
sylwiavargas profile image
Sylwia Vargas

These error messages are everyone’s dream, aren’t they? ❤️

Collapse
 
gdledsan profile image
Edmundo Sanchez

I have been writing some JS and a lot of Python due to company preferences, I keep wanting to go back to ruby everytime something is overly complicated.

however my levels of overly complicated are now quite sensible because of Ruby, ruby truly cares about you as a rubyist and your happiness and makes so much things easier, I really like that about Ruby.

I miss ruby.

Also, you made me look up the 10xEngineer again, I got angry, I might write some ruby to feel happy again.

Collapse
 
sylwiavargas profile image
Sylwia Vargas

I love this comment! You made me laugh 😂

ruby truly cares about you as a rubyist and your happiness and makes so much things easier, I really like that about Ruby.
I miss ruby.

^ that is soooo relatable. I also work a lot with other languages and frameworks and Ruby projects always feel like a safe happy place I can come and breathe. In the darkest moments when debugging the spaghetti code, just think about Ruby 💖

Collapse
 
henry701 profile image
henry701

While I agree with all the points in the post, I feel the OP should take a look at the new C# & .NET features. It also has almost everything good that was exposed about Ruby in the post.
Operator overloading, useful utility methods in LINQ, async as a first-class feature, now being cross-platform, being able to iterate over simple integer ranges, just to name a few.

PHP has also evolved pretty well on its own, but unfortunately the mentality and mechaniscs of old are still pervasive.

One particularly very good point is about readability and inclusivity in the core language. A word of caution about the community though, is that nowhere everything is all flowers. For example: web.archive.org/web/20090201190833...

Cheers!

Collapse
 
nickmaris profile image
nickmaris

Yes, stress-free testing

Collapse
 
pinotattari profile image
Riccardo Bernardini

making pointless comparisons to another language (JavaScript, for instance, which is always an easy target)

😂 This brought to my mind the Italian commercial "Ti piace vincere facile" (it is not 100% correct Italian, quite similar to "You like to win easy," error included).

Collapse
 
sylwiavargas profile image
Sylwia Vargas

Thank you for this! I just watched this commercial 😂

Collapse
 
masilver99 profile image
Michael Silver

Great post. It's definitely wonderful having a variety of programming languages and Ruby has certainly had an impact. Rails also pushed web development forward a notch or two as well.

Sadly, I'm here representing the evil empire and their offspring, C#. While opinions abound, I think there is an excellent argument for it being one of the best languages ever written. It is constantly changing and making my job easier and more fun.

Regardless of whether it's Ruby or C#, at least we found something that brings us joy. That's a win for everyone.

Collapse
 
sylwiavargas profile image
Sylwia Vargas

I agree! I would love to one day learn some C# but now I’ve just taken up Go (and next will be laravel following the recommendations of the folks in this thread).

Collapse
 
jenbutondevto profile image
Jen
for (let counter = 1; counter <= 5; counter++) {
 console.log("This could be better.");
}
Enter fullscreen mode Exit fullscreen mode

x.do is probably more similar to

let i = 0;
do {
  i += 1;
  console.log(i);
} while (i < 5);
Enter fullscreen mode Exit fullscreen mode

In terms of English, it reads the same as the ruby. "Do this block of code, while this condition".
It's a bad comparison.. I don't think I have ever needed to do something like this in js. If for example, I know I should do something 5 times based on the length of an array, I would be doing myArray.forEach((item, index) => {....}). (I imagine this is the equivalent of each_with_index you mention too).

I also find ruby, python and the like difficult to read because there aren't braces!! Creating a new instance of a class in a lot of languages look like this let jen = new Person("Jen") which is more "like English" over Person.new "Jen".

Some of your examples for array manipulation do look complicated, but they're quite outdated. Newer versions of ES, and libraries are a lot nicer to work with.

I get why a lot of people love ruby, unfortunately I don't see/benefit the upsides since I've been writing js for a while now. Some of the things you mention can be easily remedied, and really I don't see very much any more. If you're writing JS in an OO way, then SOLID is 100% possible, and is quite common. IDEs and linters will weed out anything that isn't SOLID. But it's quite common to see JS written in a FP way - especially now that React is pushing for more FP, and serverless code.

I used to hate JS for a long time. ECMA6 and beyond had made it a joy to write though.. saddens me to see JS slander heh

Collapse
 
cescquintero profile image
Francisco Quintero 🇨🇴

I think it depends on the background. In my case, English is my second language and I learnt programming in Spanish. So when I see:

for (let counter = 1; counter <= 5; counter++) {
 console.log("This could be better.");
}
Enter fullscreen mode Exit fullscreen mode

I kind of read it literally: "define variable, control condition and make sure it's increased"

While with:

5.times do
  puts "something"
end
Enter fullscreen mode Exit fullscreen mode

I read as: "print something five times".

It's just like reading some text.

I don't want to mean disrespect to JS because I've worked with it and it's nice but I think Sylwia made a good point.

Collapse
 
sylwiavargas profile image
Sylwia Vargas • Edited

Thank you for taking this time to write this comment. I totally feel what you’re saying.
My second love is JS (and especially React) — in fact, majority of my work has been done in JS. The examples I chose were definitely tongue-in-cheek and I’m sad that this was not more apparent. Well, maybe inspired by my post you’ll write a similar on about OOJS, just like I did in response to my friend 😂

I’m not here to dispute which language is better or more effective, or to “convert” anyone. As you see in the last part of the post, the real reasons why I love Ruby are subjective and personal and it’s fine if you feel another way about it!

Collapse
 
devimposter1 profile image
devimposter

To be honest I tried to get into Ruby many years ago and didn't click with it. Surprisingly I am really enjoying Elixir though that is supposed to have some similar syntax. PHP, JS and C# always came more naturally to me than Ruby. Just an opinion...

Collapse
 
sylwiavargas profile image
Sylwia Vargas

I’ve heard amazing things about Elixir and I’m curious to check it out!

Different things click for different folks ¯_(ツ)_/¯

Collapse
 
alexlion profile image
Alex Lion

I discovered Ruby along with Rails a year ago, this has literally rekindled the flame of passion for development.

I come from the JS and Java world, JS ecosystem is too messy and changing caused me the famous "JS fatigue". Java is too boilerplate.

It has been a challenge to change my way of thinking and in the end be much easier to understand and make me happier.

I've a lot to discover yet.

For PHP, Laravel is inspired by Rails but the language is too "arrowed" and not very pleasant compared to Ruby language. However Laravel has a lot of satellite projects like Nova, Forge, Vapor, Telescop which Rails is missing.

Ruby forever <3

Collapse
 
sylwiavargas profile image
Sylwia Vargas

I totally know what you mean about rekindling passion for development.

Whenever I get back to Ruby after working on a JS or React project, I always feel like some weight has been lifted off my chest.

I think I always worried of being a “declared Rubyist” because there’s just so much 10xEngineer attitude on tech twitter that bashes Ruby and Rails. But in all honesty I love React because of the features it shares with Ruby (straightforward syntax, inclusive community) so yes, Ruby is my love language 🥰

Some comments may only be visible to logged-in visitors. Sign in to view all comments.