DEV Community

Casey Brooks
Casey Brooks

Posted on

Why do people like Ruby?

I'm a Java guy and I really don't like Ruby. But a lot of people really love it. I just don't think I understand it very well, and my ignorance makes me hate it. I'm not looking to start a flame war, I'm genuinely curious as to why so many people like Ruby.

In my experience, any time I've tried to use Ruby, or a framework like Rails or Jekyll, or a tool like Vagrant or Fastlane with a Ruby config, I just find myself hopelessly confused by the very things that are touted as "Ruby's great features", and spending endless hours debugging things that turn out to just be some strange quirk of "Ruby magic".

So please, tell me why do people like Ruby, and do people ever "learn to love it" and actually pick it up after years of working with a more "traditional" or C-style language, or is it only people that started their career in Ruby that truly love it?

Oldest comments (16)

Collapse
 
ben profile image
Ben Halpern

I'd say Ruby optimizes for brain to code time, but it only works if you know and like it I'd say.

I like DHH's line about Ruby "fitting one's brain". As a Rubyist that seems to be why I keep going back to it.

Collapse
 
briankephart profile image
Brian Kephart

Ruby's flexibility and expressiveness makes it great for writing DSLs and frameworks and for writing code with very little boilerplate. The added complexity of the DSLs and frameworks often makes it hard for new Ruby devs to know what's going on.

When I was new to programming, I learned C, plus a little bit of PHP and Python. When I started using Ruby, it was just so EASY. I found myself wondering why other languages are so verbose or require byzantine syntax. I still can't understand why anyone would make a language without string interpolation.

Part of the reason Ruby seems like magic is because of its consistency in a few key areas. Everything is an object, and every expression returns an object. This leads to consequences such as implicit return and method chaining. These aren't features, necessarily, but natural consequences of the above principles. These things make perfect sense if you learned Ruby from the ground up, based on Ruby's own principles. They may be less obvious if you are trying to apply your current programming paradigm to Ruby.

Certain principles can be hard to think about in Ruby. I'm pretty sure that when Matz designed it he wasn't concerned about explaining pass-by-reference vs. pass-by-value. That's generally because Ruby encourages you to think in other ways, and that can be painful for those with experience.

I think I had an advantage learning Ruby early in my programming journey, and in learning it as a language rather than through Rails. I used Ruby Koans and CodeAcademy.

Anyway, I don't know why I typed all that. I should have just posted this link and shut up.

Collapse
 
juankortiz profile image
juankOrtiz

I was going to answer something similar to this answer, but more focused on the simplicity of its sintax.

Collapse
 
rhymes profile image
rhymes

I came from Python to Ruby so it was easy to pick up even if I didn't like at the beginning.

I honestly still don't love it (don't know, Python fits my brain better) but I'm incredibly productive with it, the community is immense and full of terrific people, Rails had a huge impact the world of web development and both Ruby and Rails are good and fast enough for most web projects.

Sometimes Rubyists take too many tangents on creating DSLs just because they can but I can live with that :D

I don't think Ruby would be as popular as it is or was without Rails.

Collapse
 
pavonz profile image
Andrea Pavoni

10+ years experienced rubyst here. before it I've used C/C++/C#/Python/PHP and so on. doing web development, I was amazed by Rails' do super SQL queries in only two lines of magic Ruby code and so I've started using it as my main language for over a decade. with time, I've also learned to tame that beast and use it in the right way.

as others already said, Ruby is a very expressive language, it lets you to write code that looks like plain english (even without using/writing a DSL).

it also looks easy at first glance, after all you can hide complex logics behind all that syntactic sugar (again, built-in or through DSL).

however, the truth is that Ruby is not an easy language, or at least, you need to know it very well if you want to master it and know what is really happening under the hood.

newcomers are often attracted by that magic, they want to learn it and start abusing DSLs, metaprogramming and all the magic stuff that Ruby offers. with time, they will learn to be more cautious about those features, to avoid shooting on their own foots :-P

my 2 cents :-)

Collapse
 
aswathm78 profile image
Aswath KNM

I'm a python guy, But when it comes to a full stack web app, I prefer Ruby on Rails.

  1. Ruby is simple and easy to learn

  2. Easy to write anything you want to,

  3. Great Community

Collapse
 
rpalo profile image
Ryan Palo

I hated Ruby the first time I tried to learn it (coming from Python). I think that the main reason was that I tried to learn Ruby and Rails all at once, diving right into Rails without getting a solid Ruby foundation. I also hated the magic and the voodoo that you had to just "assume it worked."

So I gave up.

I came back to try it again about a year later, because I really wanted to like Ruby. This time, I started with Ruby Monk, which is a great way to learn because it teaches you to do things "The Ruby Way(s)." You learn that there's not really "magic," just that some things are implicit, but predictable. Things like, "you can call a function like puts('hello') or puts 'hello', and both are OK. Once I had a solid foundation, Rails made a lot more sense, and I could see through and behind the magic. I didn't have to trust that it was working, because I knew what things were doing behind the scenes.

Now, I love Ruby! I love it because it can take really complex tasks, processes, or concepts and the code comes out looking like what you might say out loud when explaining it to your little rubber duck friend. Ruby is the only language that I've written in that I finish a block or a method and just get this feeling of

Mmm... just right.

Ahhh... that's nice. Like when you smooth the sheets on a bed down just perfect and everything is flat and smooth and all is right with the world. (Okay, maybe that example says more about my personality than how nice Ruby is, but hopefully you get the idea.)

fruits = ["apple", "pear", "bananana", "orange"]

puts fruits.sort_by { |item| item.length }
            .map { |item| item.upcase }
            .select { |item| item.length.even? }

# => PEAR, ORANGE, BANANANA
# I know banana has too many na's.  I did it for the sorting to be pretty.
Enter fullscreen mode Exit fullscreen mode
Collapse
 
whoisryosuke profile image
Ryosuke

I asked myself the same question about 10 years ago when Ruby on Rails first blew up on the scene and all the devs at Wordcamp were doing seminars on switching their stack to it. It was hard to envision why people would leave PHP for another language. And particularly at the time, I was just learning PHP, so it pissed me off that I had to learn yet another language/syntax 😣

Now reflecting, I see it like the emergence of Node. People dropped other languages like hot potatoes because of the ease and simplicity Node exhibits for certain functionality, and it's efficiency in accomplishing them (compared to PHP). Sure, I can build an API in PHP, but I can build it in Node/Ruby and have it scale better -- and interact with other devops services (possibly in other backend language I might prefer too like C or Python).

Collapse
 
lucasprag profile image
lucasprag

I love ruby because once you learned the ruby way to do things, ruby will always work the way you expect it to work.

It's impossible to talk about ruby without talking about Rails, I recommend you to read the Rails Doctrine. My favorite part is the Convention over Configuration which leads to create projects a lot faster. A lot of the most used frameworks nowadays were inspired by Rails (like Laravel for PHP and Phoenix for Elixir).

My 2 cents

Collapse
 
zenmumbler profile image
zenmumbler

I read the following post and found myself agreeing with the notion presented within:

mkdev.me/en/posts/the-three-types-...

Essentially, it argues that there are three base mindsets wrt programming and the languages you like with mindset:

  • the engineering type (likes C, Java, JavaScript, Rust, etc.)
  • the mathematical type (likes Haskell, Clojure, R, etc.)
  • the writer type (likes Ruby, CoffeeScript, "literate programming", etc)

I am very much the engineering type and regardless whether there are really 3 types or whatever, consider that programming is done by different people with very different minds and they like the languages that come naturally to their way of thinking. It's not better or worse, but different angle of approach.

Collapse
 
ozzyaaron profile image
Aaron Todd

TLDR; syntax, the community, rails, quick feedback & prototyping, mostly what I'm used to... I also think other languages and frameworks have caught up on syntax/features so the gap has closed

I'm coming from 20 years and have travelled through PHP, C, Java, a couple of .NET languages and then have been on Ruby primarily the last 7-8 years. I've continued to do PHP/C on the side.

I think it is important to say that most Rubyists come from the Rails framework which until the last 1-2 years was without question the best framework for developing any sort of prototype web application and to some extents anything that required database access. I think this is probably important to keep in mind as I think the love of Ruby is mostly tied to how well Rails stacks up to other frameworks.

I did have the opportunity to jump back to C# about 6 years ago and decided to stick with the Ruby train.

Primarily there were 2 reasons I did so:

  • I'd become accustomed to Ruby and so C-ish code rubbed me the wrong way
  • I saw a better future in teams that suit me better with Ruby

The first point is obviously really subjective. To be honest given I work in JS, PHP & Ruby regularly I know if I was forced to write Java or any language for a month I'd likely feel differently.

What I will say is that as a part-time C-ish developer and watching some of the Java and .NET developments it seems that Ruby has been quite stagnant from a syntactic POV whilst changing dramatically under the hood. Syntax is our UX and so if a language excels at syntax and structures then it will always seem 'nice'. Other languages have moved on syntactically and structurally (some driven explicitly by the popularity of Ruby/Rails like .NET and PHP) so it has become less of an issue.

I think if you give Ruby the time to get over that initial period where humans dislike change then Ruby can give you quicker feedback than pretty much anything else out there. Certainly quicker than most if not all C/Java type languages.

As to the second point this is just something I've found as you get into the Ruby community. It can quite easily be because I haven't been embedded in the Java community a while but I find Rubyists to care more about code than other communities. It is hard to explain but I found way too many grizzled old C/Java/PHP/etc devs just getting through the day compared to Rubyists.

As of the last 5 years there has also been a big revival in the Ruby/Rails community about REAL OOP which has been fantastic. It wasn't uncommon to see Ruby gain optimisations that were a decade old in other languages or presentations by developers on 'new patterns' that were also a decade old if you were paying attention. That seems to happen much less now.