DEV Community

Cover image for Unlearn programming to learn Ruby

Posted on • Updated on

Unlearn programming to learn Ruby


Ruby is a different programming language for at least 2 reasons:

The language is very permissive

Indeed, most languages are restrictive. They create constraints for developers for their "safety".

On the other hand, Ruby is a permissive language backed by a set of design principles (duck typing, etc.).

The decision to follow these design principles (or not) is the responsibility of the developer.

The vocabulary of the language is human-friendly

In most programming languages, the language is seen as an intermediary between the machine and the developer.

In Ruby, the language is apprehended as a way for the developer to express ideas in a human-friendly way - The famous Developer Happiness First adage.

Ok. So, how about slightly reshaping your way of thinking when using Ruby to enable your full potential?

The way Ruby responds to a problem

When the Ruby Core Team implements a feature, it's always focused on developer usability. That's why the language seems so natural to use

list_cart unless @cart.include? 'pineapple'
Enter fullscreen mode Exit fullscreen mode

Here, we can read this code as follows:

List the content of the cart unless the cart includes a pineapple.

In this statement, Ruby provides 3 tools:

  • the unless keyword
  • the one-liner syntax
  • the include? method

All these tools can be combined to provide a natural syntax close to what your mind can express to solve this problem. I guess you get the point here.

So, why do we need to unlearn programming to learn Ruby?

Learn to unlearn programming

It's exaggerated... You don't need to "unlearn" programming.

Because Ruby implements all the tools and concepts of CompSci. I want you to focus more about learning to "think" like a Rubyist and not like a developer.

In general, a developer adapts his way of thinking to a given program to respond to certain constraints imposed by the programming language.

So this adds layers between the developer's thoughts, the code, and the final program.

Conversely, Ruby tends to remove the barrier between developer thoughts and the code.

Now let's see how to reshape your way of thinking. To do so, there is a simple exercise that you can quickly implement:

Try to transcribe your thoughts into Ruby code.

For instance, how would you write the code for the following need in Ruby?

When the user receives a message then we send an email to this user.

Another way to express this need would be:

Send an email to the user if the user receives a message.

Keep your focus on the statement - and not the methods and objects you need to define for this statement.

For instance, I didn't define list_cart and @cart in the previous section.

list_cart unless @cart.include? 'pineapple'
Enter fullscreen mode Exit fullscreen mode

It is in a second time that I will define the content of the methods and variables that I need for this sentence.

Feel free to let a comment to share your way to express this need!


Ruby is a different programming language. The Core team genuinely believes in developer happiness. It allows you to express your thoughts as close as possible to human language.

That's why you should tend to learn and use the tools provided by the language as much as possible to transcribe your thoughts into Ruby code.

You don't have as many constraints as most programming languages. So take advantage of what Ruby gives you!

Eager to learn more about Ruby?

You can follow us on as we're very active on this platform. Indeed, we post elaborate code examples every day.

Additionally, we're currently finalizing our first online course: Ruby Mastery.

Join the list for an exclusive release alert! 🔔

🔗 Ruby Mastery by RubyCademy


Top comments (0)