Wednesday, May 23, 2012

Getting Started

As with most new endeavors, you have to start somewhere.

I have a pretty solid programming background but still wanted to start with the basics - Ruby first, then Rails. I poked around and found Mr. Neighborly's Humble Little Ruby Book. There was fortune in that name and so I went the humble route.

This guide is downloadable as a PDF, and there's an option to buy in print if you want to slaughter a few trees. It's written in a conversational tone that provides a bit of levity but also adds significantly to the overall word count - you'll want to skim over some of the comical asides.

A good job is done by Mr. Neighborly of starting from the very beginning - the origins of Ruby, installation guides, etc. From there you'll get into the ubiquitous "Hello World" example, and then move through the standard Ruby data types, using methods and procs, and then into some more detailed examples.
Having come from the worlds of Java / C++ / C#, a couple of Ruby concepts were new to me.

Everything is an Object - Yep, everything. You can do semi-unnatural things like call methods on numbers. For example:

# The absolute value method is used to set the variable my_num to 4 my_num = -4.abs

Ruby is a Dynamic Language - There are a couple of immediate implications to this.
  1. As you can see from the above example, you don't declare a type when creating a variable. Simple enough, but it takes some getting used to
  2. Intellisense functions that you may be used to don't really work. At least not in Aptana Studio 3, which is the IDE I sort of randomly choose to begin work. I'm assuming this is because an an object can be any type, the IDE can't predict which methods to show you.

Ruby has lots of other conventions and syntax that take a bit of getting used to, but no more so than leaning any other language.

1 comment:

  1. Ruby Koans is a pretty interesting approach to some of the subtleties of Ruby: http://rubykoans.com/

    And as for a Rails environment, I've found Sublime Text 2 (basically a really powerful text editor) and a command prompt to be much better than Aptana Studio or any of the other IDEs. I also finally gave up on doing Rails dev on Windows -- to much flakiness and installed Ubuntu on an old laptop, though most Rails developers prefer OS X if you have access to a PowerBook.

    ReplyDelete