DEV Community

Discussion on: Why do you love Ruby, actually? An ode.

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!