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?

Top comments (16)

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.

juankortiz profile image

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

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 :-)

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? }

# I know banana has too many na's.  I did it for the sorting to be pretty.
Enter fullscreen mode Exit fullscreen mode
zalom profile image
Zlatko Alomerovic • Edited

Back in 2001, freshmen year at college, I was wondering why simple "Hello World!" in C had to look like:

#include <stdio.h>
int main()
   printf("Hello, World!");
   return 0;
Enter fullscreen mode Exit fullscreen mode

Back in 2003, I was wondering why a simple "Hello World!" in C++ had to look like:

#include <iostream>

int main()
  std::cout << "Hello World!" << std::endl;
  return 0;
Enter fullscreen mode Exit fullscreen mode

Back in 2007, I was wondering why the simple "Hello World!" in Java has to look like:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello, World");
Enter fullscreen mode Exit fullscreen mode

In 2008, I found out that it can look like:

puts 'Hello World!'
Enter fullscreen mode Exit fullscreen mode

I was never looking the other way!

Btw., I am an engineer.

zenmumbler profile image

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

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.

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.

dfockler profile image
Dan Fockler

Ruby was the first language I learned that felt really fun. It didn't feel like I was fighting a rigid system to get things done, and I wasn't writing unnecessary glue code or helper methods everywhere.

In school I had originally learned Java and then did about 5 years of PHP/JS development work. Finally I got a job doing Ruby after being a fan of the language since college. Ruby just works with my brain instead of getting in the way of it.

whoisryosuke profile image

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).

revof11 profile image
Joe Brutto

I came from Java and C/C++. I've been using Ruby on Rails for a while now and just have not learned to love it. In fact, I've been trying to weed it out of my projects with few exceptions.

Without getting into the weeds (I want to keep this short), my least favorite thing in the Rails world is ActiveRecord (and AR migrations). It's mostly the same reasons I never liked Hibernate in the Java world and fell back onto MyBatis (and Flyway). Complex queries in ActiveRecord (and Hibernate) are an absolutely nightmare, but trivial and much more common queries are fast and easy.

When it comes to basic, web-facing entry points for an application I can still see it used. When it comes to microservices and wanting performance in systems it just can't beat other languages. For large data transformations and hefty calculations I've had more luck using languages focused on those things as their speciality.

That being said, I think we live in a world now where using a single language to accomplish everything in your system is ludicrous. The days of "we are an XYZ shop" are almost over. A good cloud architecture uses whatever is best for the task at hand. For a website or a prototype? PHP and Ruby on Rails are perfect. Any engineer worth their salt, though, knows AT LEAST 3 languages inside and out.

In a lot of systems I've worked on lately I've seen a mix of Java, Go, Python and even some C# in some places. For people doing nifty things with Nginx I've seen some neat C, too. Ruby comes in mostly when I see people using Chef, Terraform, etc. where I think it is a great fit.

Monolithic systems are on the out and microservices are on the in. RoR/Passenger, RoR/Unicorn and things like Java/JBoss, Java/WebLogic, etc. are LESS necessary in many enterprise apps now. They absolutely have their place, but things like Kubernetes help alleviate some of the headaches they caused as well.

There's some other things that bug me about Ruby "stuff I see frequently": not being strict type safe (I dislike dynamic typing pretty strongly), overuse of hashes instead of classes (except in the case of things like parsing JSON where it is great), lack of distinction between arrays, lists, sets, vectors, etc., using AR all over the code instead of having shared DAO services, using AR migrations instead of direct SQL (heck, we have Docker now so you don't need to test on SQLite and deploy on MySQL) and some other stuff.

Again, I see it's place, but I just don't love it. I can see its use for scripting, but I prefer Bash for that and fall onto Python when Bash doesn't cut it.

I dunno. Just my opinion.

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

rhymes profile image

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.

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.

bubuzzz profile image
Thai Tran

New learner here. Been a Java developer for more than 10 years along with several projects with Python, Golang, Coffeescript/Typescript/Javascript (Nodejs) as well, I thought I hated Javascript relatives the most until I had a task to maintain a fairly big codebase of Ruby on Rails now. To be honest, I can not be productive in just 1 or 2 days, and also, I can not just go to the project, hack around and then do the task like Go. I have to understand Ruby first, which has a super weird syntax for me now because Ruby syntax is totally different from all the things I knew, so the learning gap for me is high (:symbol, "string".freeze, ....). Then after that, I have to learn the magic of Rails, where params/session out of nowhere suddenly can be used, where the "a_b_path" actually indicates that it will call a rendering function from some files.

Yes, I know that if I have time, eventually I will like it, love it, and cannot live without it, but now I don't have that precious time, even right now I have the biased frustrated feeling about learning it as well (sigh)

yashiroquy profile image
UMR • Edited

My boss also forced me to jump into rails without any prior knowledge including ruby. It is so confusing and I don't like the implicity of rails at all.

lucasprag profile image

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