So you want to learn Ruby. Here’s how.

S

Ruby is great. I love Ruby. Lots of people love Ruby. I’d argue that you’d be hard-pressed to find more Ruby die-hards than you would Python, PHP, or Go. Ruby is cool. Ruby is straightforward. Ruby is effortless. Ruby just makes sense most of the time[0].

Operating System
Disclaimer

If you’re on Windows 8 or older you’re going to have a bad time long-term. If you’re on Windows 10 you can probably get away with Windows 10 Subsystem for Linux.

Preferred

The most preferred Ruby environment is MacOS/OS X, followed by Ubuntu (or any Linux distro, really).

Software
Ruby

There’s already thousands of guides on how to install Ruby on your operating system. I’d consult Google for those.

Text editor

Go ahead and download Sublime Text or similar text editor.

More important than you think: Whatever you do, make sure you have some sort of add-on/extension/plugin for checking your code’s style against the Ruby Style Guide. This is very important. You will have a much more enjoyable experience if you’re styling your code like everyone else. It’s like having great communication by default. Good habits start young, too.

Learning
Syntax

Before you start writing actual Ruby that does something, I’d first familiarize yourself with the syntax and some of the core principles. Learn ruby in Y minutes is great for this.

Actual code

Learn Ruby The Hard Way is great. It’s an easy read with lots of discussion scattered throughout the internet.

Books

I’m a huge fan of Sandi Metz. POODR and 99 Bottles should be on your reading list. Idiomatic Ruby, Eloquent Ruby are also great.

Repos

If you’re new-er to programming or haven’t a formal computer science education or foundation, I’d recommend at least a glance at some common design patterns written in Ruby. https://github.com/nslocum/design-patterns-in-ruby

When I have questions about how someone does something I frequently visit some of the well-known open-source Ruby projects. Because I work a lot with Rails, my preferred repos are built with Rails, but are by no means specific to Rails. GitLab is my go-to.

Frequently asked questions
A lot of these books/resources are for 1.9. The current version is 2.4. What gives?

Admittedly, Ruby’s heyday has passed. That’s not to say that Ruby isn’t still immensely popular or used. People are just talking about newer technologies. We still use microwaves, don’t we?

Having said, these books were published because there was overwhelming demand for Ruby knowledge when they were written. The Ruby version during that period was, well, not the version it is now.

The changes between 1.9 and 2.x are mostly adding features or cosmetic — like colons/hashrockets for hash keys. I can’t remember a time when I went, “darn, that’s only for 1.9.” I don’t think you will either.

What’s Ruby good for?

Its popularity is rooted in web applications using the Rails framework. Sinatra is also a popular framework, though less used in production-grade and complex web apps.

I’ve heard of Rails. Where do I learn Rails?

The idea of “learning Rails” baffles me.

Rails is a framework written in Ruby. It’s popular because it eliminates a lot of the thinking you have to do, therefore you can get more stuff done.

A lot of people come to Ruby to work on/with Rails. No mid-level or senior Ruby/Rails developer will ever suggest starting with Rails before you really understand Ruby fundamentals and are familiar with Ruby best-practices and the community style guide.

Those who run before they can walk are able to use Rails generators, sure. They’ll understand the basics of MVC. They’ll know how to add a route to the HTTP service. But they don’t (and won’t) understand how it works or why it works the way it does, where the magic happens and how it happens, and it shows in their code, their habits, and their thinking.

Okay, but I want my stuff to be web-facing. What do I do?

Once you go through the aforementioned resources and have a solid foundation in Ruby, I’d recommend reading up on Rack and Rack::Web. You’ll quickly find yourself using Sinatra. Once you understand how Sinatra works, I’d then recommend whipping out Rails.

[0] String#upcase and String#downcase notwithstanding

Add comment

By Josh