Idea: Ruby Tutorial For Newbies

Discussion in 'Ruby' started by simonh, Jan 15, 2006.

  1. simonh

    simonh Guest

    Hello all. I am learning to program with ruby but I'm struggling to
    find a really good tutorial or book aimed at beginners. The pickaxe 2nd
    ed. is an incredible book but can be a little intimidating for
    beginners. Many of the other books cover ruby 1.6. The available
    tutorials I've found either don't go far enough or spend too long
    telling stories (sorry Why)! Anyway, I think it would be beneficial to
    have a set of tutorials in the form of dialogues similar to the
    artcompsci project:

    link: http://www.artcompsci.org/kali/development.html

    but aimed at non mathematical problems. Here is a sample of what I am
    proposing: (bear in mind I am a newby too). I think it would be better
    for a ruby guru to write the dialogues.

    -----------------------------------------------------------------------------------------------------------------------------------
    T- Teacher
    S- Student


    T: Ok lets get started. Here is a 'hello world' program. This is
    usually the first program a student writes in any programming language.
    All it does is print the phrase Hello World onto the screen.

    puts "Hello World"


    >Hello world



    T: How do you think this program works?


    S: It looks to me like the word puts is a command. The phrase Hello
    World is the text that the command should print out. I'm not sure why
    the phrase is quoted though. The quotes don't appear on the screen.

    T: Well spotted. The phrase Hello World is what we call a String. We
    identify Strings by enclosing text within quotation marks. We use
    single ( ' ) and double ( " ) quotes in Ruby. We'll come to the
    differences between using single or double quotes later on. You
    suggested that puts was a command. In fact it's a method. Methods are a
    core concept of Ruby so fix that in your mind. Here is a description of
    what the program is doing: The method puts receives the String Hello
    World as its argument. puts is a method defined in the Kernel module.
    We'll come to that later as well.

    S: Does it matter if puts is upper or lowercase?

    T: Try it out

    S: Puts "Hello World"

    >beginner.rb:1: undefined method `Puts' for main:Object (NoMethodError)
    >Exit code: 1


    S: Obviously it doesn't work. An error message has been printed.

    T: You should get used to reading error messages straight away. Ruby is
    telling us that the error occurred in line 1 beginner.rb:1 it then
    tells us the error. We have not defined a method 'Puts' for main:Object
    In Ruby methods should always be lowercase. Classes, Modules and
    Constants are uppercase. For now don't worry about any of these new
    terms. We will cover them before long.

    S: It seems there is a lot of stuff we will be covering later on!

    T: Yes I know. Its quite hard to know where to start with someone who
    has no programming experience. My plan is to introduce you to some
    basic Ruby and then explain things at the right time. I promise you'll
    understand all of these concepts before long.

    S: Ok, I'll take your word for it. What's next?

    T: Rather that use the method puts we can use print instead

    print "Hello World"

    >Hello World


    T: The difference is that puts will print the string and insert a
    newline character where as print will not. See the cursor is now on the
    same line? Change print to puts and see where the cursor is then.

    S: Oh right. Yep I see what you mean.

    T: Try this

    puts "Hello World"
    puts "I am learning Ruby!"

    >Hello World
    >I am learning Ruby!


    T: Now do the same thing with print

    print "Hello World"
    print "I am learning Ruby!"

    >Hello WorldI am learning Ruby!
     
    simonh, Jan 15, 2006
    #1
    1. Advertising

  2. simonh

    simonh Guest

    Maybe people could volunteer to do a chapter.

    The Basics
    Classes and Modules
    Variables
    Ruby Way
    Regular Expressions
    IRB
    etc


    The possibilities are endless. The entire standard library could be
    covered?
     
    simonh, Jan 15, 2006
    #2
    1. Advertising

  3. simonh

    anne001 Guest

    >I've found either don't go far enough or spend too long
    >telling stories (sorry Why)


    What you are proposing seems to me to have too many words, and to
    suggest something so basic, it won't go anywhere fast.
     
    anne001, Jan 15, 2006
    #3
  4. simonh

    anne001 Guest

    >I've found either don't go far enough or spend too long
    >telling stories (sorry Why)


    What you are proposing seems to me to have too many words, and to
    suggest something so basic, it won't go anywhere fast.
     
    anne001, Jan 15, 2006
    #4
  5. simonh

    Guest

    , Jan 15, 2006
    #5
  6. simonh

    simonh Guest

    thanks for the replies everyone. had a new idea - the pickaxe
    companion. the new idea is to expand on the ideas from that famous book
    with more concrete, real world examples.

    richhg12hs - yes seen that tutorial. not the updated version though. it
    looks very good. i'm going to read through it now
     
    simonh, Jan 15, 2006
    #6
  7. simonh

    simonh Guest

    i think i'd better buy 'learn to program' by chris pine. this might be
    just what i need
     
    simonh, Jan 15, 2006
    #7
  8. What about http://tryruby.hobix.com/ ? It actually works the way you
    describe for the most part. It's a lot more down to earth than say the
    Poignant Guide ;) The scripts Why uses are just basic htm with some
    class markup, so anyone can make new ones.
    .adam
     
    Adam Sanderson, Jan 16, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Juan Antonio Agudo

    [INFO] Tomcat Tutorial for newbies

    Juan Antonio Agudo, Jan 14, 2004, in forum: Java
    Replies:
    0
    Views:
    550
    Juan Antonio Agudo
    Jan 14, 2004
  2. sham3036
    Replies:
    0
    Views:
    654
    sham3036
    Jul 14, 2006
  3. Replies:
    10
    Views:
    1,248
    Big K
    Feb 2, 2005
  4. Alf P. Steinbach

    How we recognize newbies as newbies

    Alf P. Steinbach, Aug 13, 2007, in forum: C++
    Replies:
    31
    Views:
    1,121
    Diego Martins
    Aug 21, 2007
  5. Dr Mephesto

    App idea, Any idea on implementation?

    Dr Mephesto, Feb 4, 2008, in forum: Python
    Replies:
    3
    Views:
    725
    Dennis Lee Bieber
    Feb 5, 2008
Loading...

Share This Page