[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Idea: Ruby Tutorial For Newbies

simonh

1/15/2006 11:44:00 AM

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/develo...

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!

8 Answers

simonh

1/15/2006 12:00:00 PM

0

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?

anne001

1/15/2006 1:48:00 PM

0

>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

1/15/2006 1:48:00 PM

0

>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.

HT de Beer

1/15/2006 2:14:00 PM

0

anne001 wrote:

>>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.

I think she is right here. The biggest problem with writing texts for
beginners is that there is no stereotype beginner. So to attract a bigger
audience, you will have to write somewhat more general and compact than you
have proposed.

Furthermore, to attract people to your text and keep them attracted, you
have to give them a reason to read on. Going into details of many
variations of the 'hello world!' program is not going to work. I can advise
you to work towards a `real' program as fast as possible and inform the
reader about the real program.

Besides that, people who already know how to program and are willing to
learn Ruby, won't like to be treated as complete nitwits. Complete nitwits,
on the other hand, who want to learn programming and are using Ruby as
their first language, may like your proposed style. Unfortunately, I do not
know if it is the best way to learn programming, it seems to me too much
focused on details of ruby and too less on programming in general.

So try to find out who your audience is, and write for them. Let them
regularly read your text, and use their remarks to improve your text.

--
HT de Beer

rickhg12hs

1/15/2006 2:45:00 PM

0

Have a look at Chris Pine's Tutorial:

http://pine.fm/Learn...

Is this what you've been looking for?

simonh

1/15/2006 3:22:00 PM

0

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

1/15/2006 3:36:00 PM

0

i think i'd better buy 'learn to program' by chris pine. this might be
just what i need

netghost

1/16/2006 5:49:00 PM

0

What about http://tryruby.... ? 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