Thursday, November 22, 2012

Learning Ruby and Rails

Note: This post on Ruby and Rails is the final one in a series on Learning How to Program. Previous posts were: Picking a Language, General Tips, Java and Python, and Web: HTML, Javascript, PHP

Say you don't want to edit old PHP scripts, but instead want to create your own new web application. A good choice would be Ruby on Rails, the 'cool' framework for creating websites. It contains various tools and elements that are common to most web applications so you do not need to re-create them from scratch in your own website.   For example, most web apps have forms that take user data and place them in a database. Ruby on Rails lets you create such forms quickly and securely. Rails is written in Ruby, so to code with Rails, you will need to know some Ruby. While you don't actually have to spend that much time coding with Ruby before starting Rails, I think it makes more sense for a beginner to get comfortable with programming basics before taking on a complex web framework.

Ruby
As always, it's good to jump right in with an interactive tutorial, which there is no lack of in Ruby. You can spend a few minutes on TryRuby and then look at Codecademy or go through slightly more advanced material on RubyMonk, which has 1 free course and additional courses for $10/month. If you like videos, you can pay $25/month and get access to CodeSchool's courses, including RubyBits.

You should have a book also though. Learn to Program is geared at teaching programming concepts to beginners, and they aso have a more recent paid edition. The Humble Little Ruby Book is good for learning Ruby, though if you prefer more attitude and random cartoons, there's the famous Why's Poigant Guide to Ruby. If you have more experience and really want to get experienced at Ruby, there's the Pickaxe Guide.

If you want to download something to teach kids Ruby, there's Hackety-Hack, and if they're just interested in games, there's Ruby4Kids.

Ruby on Rails
After learning the basics of programming and Ruby, you can start learning Rails, which also has interactive tutorials. CodeLearn recently launched to let people learn Rails by trying out things from within their browser. If you like learning by watching zombie videos, check out CodeScool's famous RailsForZombies. You can then signup to CodeSchool and get access to the sequel.

The 'official' free text to learn Rails is the Ruby on Rails Tutorial, which goes through all the details on how you would create a Twitter-clone, from getting things installed to version control, from "rails-flavored" ruby to nice CSS styles, and of course, all the fundamentals of Ruby on Rails.
The book places a strong strong emphasis on writing test code, which is code that tests out your main code to ensure it does what you want it to. It follows the TDD and BDD processes, which means you write the tests before you write your actual program's code. Sometimes you will spend more time writing the tests than actually writing the rails code, but this way you will know your software always works. You can always skips some of the test-parts if you feel its too much.
The issue with a step-by-step tutorial book is that you need to make sure you think about how to do things, and not just copy what the book says. It might be helpful to try to figure out what to do before looking at the code in the book, though that won't always be possible.

If you have a little experience, you might like Agile Web Development with Rails, which goes through how to create a shopping-cart application in part 1, and contains a rails reference in part 2. To learn how to do specific things, you can watch the screencasts on Railscasts. There's also the official Rails Guides, which cover various aspects of Rails.

Of course, to actually learn Rails or programming well, you need to work on your own projects. As mentioned, you should find someone to help you work through a project. If you have a couple months, you could consider signing up at one of the Rails bootcamps that sprung up recently. Devbootcamp pioneered the bootcamp approach in SF, AppAcademy  claims they'll only charge you if you get a job, Starter League is well-established in Chicago and Flatiron School recently started in NY. They charge $8k - 12k, but many give partial refunds if you take a job with one of the companies they're connected with.

With all these resources, it's easy to try out programing and then pursue it further if you like it.

5 comments:

  1. [...] The previous chart helped beginners pick a language, this one shows them what resources to use to learn it. It’s better to spend time doing things than to passively read or watch content, so I selected interactive websites, books and courses. Start by going through an online tutorial, and then either read through some of a book or watch an online course. Personally I think a book is better than a video since they’re more concise and easier to reference, but most videos below are short and to the point. The chart is based on these posts: Picking a Language, General Tips, Java and Python, Web: HTML Javascript and PHP, Learning Ruby and Rails [...]

    ReplyDelete
  2. [...] I realized that one chart was able to encapsulate the important information from 3 previous blog posts. This makes me think there might be too much of a bias to write content in a specific form and [...]

    ReplyDelete
  3. Thanks Ariel for including the mention of Codelearn. I am one of the founder. Dropping this comment so that if your audience has any query/issue related to our Ruby on Rails basic course, they can ask here as I would be listening.

    Also, I have this quick input/disagreement to your blog. I learnt Rails myself around 2 years ago & I did not choose to pick up Ruby because I realized it was not required. I have covered it in details in the later part of the Philosophy page - http://www.codelearn.org/ruby-on-rails-tutorial/Codelearn-philosophy

    IMHO - the Michael Hartl guide to learn Rails is the best among all the tutorials I could lay my hands on & we plan to make Codelearn better than that :). Do let us know how are we doing & how can we improve.

    ReplyDelete
  4. You may not need that much Ruby knowledge to start with Rails, but I think someone without programming knowledge should start with something simpler than a large framework. They could quickly create a simple program in Ruby which they fully understand, but it takes much longer to get comfortable with Rails.

    ReplyDelete
  5. May be you are right. When I picked Rails, I was conversant with PHP & some other languages.

    But in the hindsight, I am not sure if all that knowledge really helped when I picked Rails. Rather, I needed to unlearn lot of things which I picked earlier.

    I had a friend who picked Rails as part of his first web development project. He has been working on things like C, C++ prior to that. Guess he also got started with Rails directly & picked Ruby as & when required. I emulated his approach in Codelearn.

    ReplyDelete