Becoming a Ruby on Rails Developer: 1 year later

·

3 min read

I am approaching a one-year work anniversary at an awesome, creative company that uses Ruby on Rails to do some incredible stuff. I will admit that I was hesitant at first -- I have heard many developers online and IRL comment on how the language and framework are outdated, long since replaced with more powerful alternatives. I don't think those people have any idea what they're talking about. Ruby on Rails is a flexible, fast, and scalable tool that is quietly powering some of the most popular sites on the web.

Here's what to expect if you're getting started on your Ruby on Rails journey.

There is a learning curve

Ruby looks and behaves differently from any other programming language I've dealt with. At first, it can be very difficult to look at a bit of Ruby code and understand what is going on. You will see symbols all over the place, which can be a big concept to wrap your head around. (:symbols look :like_this.) Hashes are sort of like objects in JavaScript, but not really. ({ :key => 'value' })

One of the biggest reasons for the learning curve is that...

There are many ways to do things

You can push things into an array like this:

array = Array.new
array.push(1)
# OR
array << 1

You can call a method with or without parentheses:

def my_global_method(a,b)
  a + b
end

...

def test_calling_global_methods
  assert_equal 5, my_global_method(2,3)
end

def test_calling_global_methods_without_parentheses
  result = my_global_method 2, 3
  assert_equal 5, result
end

You can even iterate through an array with a completely different syntax:

  def test_iterating_with_each
    array = [1, 2, 3]
    sum = 0
    array.each do |item|
      sum += item
    end
    assert_equal 6, sum
  end

  def test_each_can_use_curly_brace_blocks_too
    array = [1, 2, 3]
    sum = 0
    array.each { |item| sum += item }
    assert_equal 6, sum
  end

The examples above were taken from the Ruby Koans. These exercises are hands down the best way to get familiar with the way Ruby works. If you are an aspiring Ruby developer, start here.

Community is key

Finding good documentation or tutorials for Ruby or Ruby on Rails can feel like hunting through an ancient library for esoteric forbidden knowledge. There is a lot of garbage out there, a lot of outdated information, and a lot of different viewpoints. More than any other language I've worked in, it is important to find resources and people who you trust. Your best resource will most likely be the development team you are working with.

Here are some resources I suggest:

Everything is an object

Another example from the Koans...

  def test_everything_is_an_object
    assert_equal true, 1.is_a?(Object)
    assert_equal true, 1.5.is_a?(Object)
    assert_equal true, "string".is_a?(Object)
    assert_equal true, nil.is_a?(Object)
    assert_equal true, Object.is_a?(Object)
  end

In Ruby, everything is an object. This is part of the magic.

In Practical Object-Oriented Design, author Sandi Metz describes the world as object-oriented:

The objects with which you interact might include a spouse and a cat, or an old car and a pile of bike parts in the garage, or your ticking heart and the exercise plan you use to keep it healthy. Each of these objects comes equipped with its own behavior, and while some of the interactions between them might be predictable, it is entirely possible for your spouse to unexpectedly step on the cat, causing a reaction that rapidly raises everyone's heart rate and gives you new appreciation for your exercise regimen.

...

Failures of OOD [object-oriented design] might look like failures of coding technique, but they are actually failures of perspective.

Coding in Ruby and working with Rails will give you a whole new perspective. It's been quite the journey, and I still feel like I'm at the very beginning of a whole new world.