[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

I’m having a hard time learning ruby.

Nate Imaqaguy

8/3/2006 6:06:00 PM


For starters, just do you know where Iâ??m coming from: I have little to
no programming experience, except for some C and VB classes I took 6
years ago, which I did fine in.

My biggest hurdle getting started with ruby is finding which
methods/classes/files to call upon for whatever the heck Iâ??m trying to
accomplish.

Iâ??m use to being able to perform a search, like in MSDN Library, using
key words of something Iâ??m trying to perform. Then research results
from there, and get pointed in the right direction (with explanations on
what the feature does, and examples, etc).

The editors also helped with showing the available methods, as I wrote
the code.

So, with ruby, Iâ??m using the SciTE editor (on WinXP), which doesnâ??t give
method options as you go. Yeah, I know they are kinda like training
wheels, but they help when youâ??re starting out.

And I canâ??t really find any close equivalent to using something like an
MSDN Library. The best thing someone has pointed me to so far is
http://www.rub.... Which is cool and all, but itâ??s not really
â??searchableâ?â??you kind of have to know what file/class/method to look up
in the first place. And even if I find what I think Iâ??m looking for,
the documentation is confusing to me. Sometimes there isnâ??t the
slightest word as to what something does.

Someone told me about â??.methodsâ?, but that only works if youâ??re in an
irb session, which I find painful to use because I have to type all my
code in, line by line. I canâ??t even figure out how to paste each line
of the code I already have. Inevitably I fat finger something and get
mad.

So, you can kinda see a n00bs frustrationâ?¦.

I must be missing something big. Any tips (other than â??try not to suck
so much�)?

= )

--
Posted via http://www.ruby-....

29 Answers

Matt Todd

8/3/2006 6:10:00 PM

0

Do you have the Pick-Axe (Programming Ruby from the Pragmatic
Programmers)? If not, I highly recommend you pick that up. And, while
you're at it, pick up the Ruby Recipes, which will have tons of
example code for all kinds of things you might want to do!

M.T.

yesmar@speakeasy.net

8/3/2006 6:11:00 PM

0

Just read this: http://www.rubycentral...

---
Ramsey <yesmar@speakeasy.net>
GPG fingerprint = 0E28 4713 428E AC4E AE05 A4A6 D70B 321D 7188 3AD0


On Aug 3, 2006, at 11:05 AM, Nate Imaqaguy wrote:

>
> For starters, just do you know where I’m coming from: I have little to
> no programming experience, except for some C and VB classes I took 6
> years ago, which I did fine in.
>
> My biggest hurdle getting started with ruby is finding which
> methods/classes/files to call upon for whatever the heck I’m trying to
> accomplish.
>
> I’m use to being able to perform a search, like in MSDN Library, using
> key words of something I’m trying to perform. Then research results
> from there, and get pointed in the right direction (with
> explanations on
> what the feature does, and examples, etc).
>
> The editors also helped with showing the available methods, as I wrote
> the code.
>
> So, with ruby, I’m using the SciTE editor (on WinXP), which doesn’t
> give
> method options as you go. Yeah, I know they are kinda like training
> wheels, but they help when you’re starting out.
>
> And I can’t really find any close equivalent to using something
> like an
> MSDN Library. The best thing someone has pointed me to so far is
> http://www.rub.... Which is cool and all, but it’s not really
> “searchable”—you kind of have to know what file/class/method to
> look up
> in the first place. And even if I find what I think I’m looking for,
> the documentation is confusing to me. Sometimes there isn’t the
> slightest word as to what something does.
>
> Someone told me about “.methods”, but that only works if you’re in an
> irb session, which I find painful to use because I have to type all my
> code in, line by line. I can’t even figure out how to paste each line
> of the code I already have. Inevitably I fat finger something and get
> mad.
>
> So, you can kinda see a n00bs frustration….
>
> I must be missing something big. Any tips (other than “try not to
> suck
> so much”)?
>
> = )
>
> --
> Posted via http://www.ruby-....
>


Dark Ambient

8/3/2006 6:16:00 PM

0

As a newb myself I always find some delight in the realization that
other people are struggling as well. So, in reality I can't address
specifically the parallels you are looking for between past languages
and Ruby.
My suggestion though would be to read up , books, like Programming
Ruby, edition 1 is available online and 2nd edition for sale as a pdf
and / or hard copy. IRB is your friend because it helps you test code
in a very fast way. I do believe one thing - that the time you study
and soak in the material will be returned via Ruby's incredible
pseduo-code like style. There are many methods that will make things
so much easier then most other languages. Maybe I'm just naive and
could even be wrong but after about a month now , is how I see things.

Stuart

On 8/3/06, Nate Imaqaguy <breakingsoftware@gmail.com> wrote:
>
> For starters, just do you know where I'm coming from: I have little to
> no programming experience, except for some C and VB classes I took 6
> years ago, which I did fine in.
>
> My biggest hurdle getting started with ruby is finding which
> methods/classes/files to call upon for whatever the heck I'm trying to
> accomplish.
>
> I'm use to being able to perform a search, like in MSDN Library, using
> key words of something I'm trying to perform. Then research results
> from there, and get pointed in the right direction (with explanations on
> what the feature does, and examples, etc).
>
> The editors also helped with showing the available methods, as I wrote
> the code.
>
> So, with ruby, I'm using the SciTE editor (on WinXP), which doesn't give
> method options as you go. Yeah, I know they are kinda like training
> wheels, but they help when you're starting out.
>
> And I can't really find any close equivalent to using something like an
> MSDN Library. The best thing someone has pointed me to so far is
> http://www.rub.... Which is cool and all, but it's not really
> "searchable"—you kind of have to know what file/class/method to look up
> in the first place. And even if I find what I think I'm looking for,
> the documentation is confusing to me. Sometimes there isn't the
> slightest word as to what something does.
>
> Someone told me about ".methods", but that only works if you're in an
> irb session, which I find painful to use because I have to type all my
> code in, line by line. I can't even figure out how to paste each line
> of the code I already have. Inevitably I fat finger something and get
> mad.
>
> So, you can kinda see a n00bs frustration….
>
> I must be missing something big. Any tips (other than "try not to suck
> so much")?
>
> = )
>
> --
> Posted via http://www.ruby-....
>
>

Chad Perrin

8/3/2006 7:10:00 PM

0

On Fri, Aug 04, 2006 at 03:05:41AM +0900, Nate Imaqaguy wrote:
>
> My biggest hurdle getting started with ruby is finding which
> methods/classes/files to call upon for whatever the heck I’m trying to
> accomplish.
>
> I’m use to being able to perform a search, like in MSDN Library, using
> key words of something I’m trying to perform. Then research results
> from there, and get pointed in the right direction (with explanations on
> what the feature does, and examples, etc).

That seems to be a common problem for languages I like: discoverability
sucks (relative to that in languages I don't like, unfortunately). One
tends to end up needing to ask questions of people rather than simply
looking up the answers oneself, much of the time. Somehow, I've managed
anyway.

It mostly sounds like what you need is a good reference, and not so much
an instructional book. I hesitate to say "go spend money" -- it would
be awfully nice if there were a free solution to this problem. I don't
really see such a thing available, though. As such, perhaps you should
look into getting O'Reilly's "Ruby In A Nutshell". The Nutshell series
of books from O'Reilly are designed specifically as references full of
listings of the options available, with brief descriptions, presented in
a non-tutorial, searchable manner. If you get an O'Reilly CD Bookshelf
for subjects of interest, you'll likely end up with a digital copy of
the Nutshell reference for that subject matter, which makes it even more
searchable. I don't even know whether there's a CD Bookshelf for Ruby,
though, unfortunately.


>
> So, with ruby, I’m using the SciTE editor (on WinXP), which doesn’t give
> method options as you go. Yeah, I know they are kinda like training
> wheels, but they help when you’re starting out.

On the rare occasion when I find myself forced to work with text files
of any sort (source code, notes to self, et cetera) on a Windows
machine, SciTE is definitely my preferred way to do it. It's an
excellent programming, and general purpose, text editor. The fact that
it's not designed by someone who's trying to push a programming language
"product", however, ensures it's not going to be encumbered by language
documentation. The lack of such does have its downside.

I wish I had more useful advice to offer on the subject.

--
CCD CopyWrite Chad Perrin [ http://ccd.ap... ]
"The measure on a man's real character is what he would do
if he knew he would never be found out." - Thomas McCauley

Morton Goldberg

8/3/2006 7:24:00 PM

0

My recommendation is: go to

http://pragmaticprogrammer.com/titles/ruby/...

Order both the print and PDF versions of the Programming Ruby book --
you get a special price if you order both together. The PDF is
searchable on your computer in the way that have described.
I find myself searching it several times every day.

Your frustration level and blood pressure should quickly return to
normal :)

Regards, Morton

Leslie Viljoen

8/3/2006 7:28:00 PM

0

On 8/3/06, Nate Imaqaguy <breakingsoftware@gmail.com> wrote:
>
> For starters, just do you know where I'm coming from: I have little to
> no programming experience, except for some C and VB classes I took 6
> years ago, which I did fine in.
>
> My biggest hurdle getting started with ruby is finding which
> methods/classes/files to call upon for whatever the heck I'm trying to
> accomplish.
>
> I'm use to being able to perform a search, like in MSDN Library, using
> key words of something I'm trying to perform. Then research results
> from there, and get pointed in the right direction (with explanations on
> what the feature does, and examples, etc).

I find VS.NET 2003 has a fast and useful help system, but 2005 is way
slow. With Ruby I have a PDF of the Pickaxe book and also bought the
PDF version of Hal Fulton's "The Ruby Way". Using the latest Acrobat
Reader's search features, I get close to the MSDN effect. Beyond that
I use the "Forum Search" - ask a question on Ruby-Talk and normally
within 5 minutes you have 5 answers!

> The editors also helped with showing the available methods, as I wrote
> the code.
>
> So, with ruby, I'm using the SciTE editor (on WinXP), which doesn't give
> method options as you go. Yeah, I know they are kinda like training
> wheels, but they help when you're starting out.

I think normal Intellisense would be impossible to do for Ruby because
every variable can be any object at any time. So an editor would have
to run your program to find out what methods a variable supports at a
certain point. That said, Radrails does have limited code completion.

> And I can't really find any close equivalent to using something like an
> MSDN Library. The best thing someone has pointed me to so far is
> http://www.rub.... Which is cool and all, but it's not really
> "searchable"—you kind of have to know what file/class/method to look up
> in the first place. And even if I find what I think I'm looking for,
> the documentation is confusing to me. Sometimes there isn't the
> slightest word as to what something does.

You should buy the PDF versions of a couple of Ruby books and search them.

> Someone told me about ".methods", but that only works if you're in an
> irb session, which I find painful to use because I have to type all my
> code in, line by line. I can't even figure out how to paste each line
> of the code I already have. Inevitably I fat finger something and get
> mad.

I often start in IRB and then make a mistake and have to do it all in
the editor again. Best to just use an editor. Scite can run your code
quickly - just go to Tools->Go. Radrails can also run your code inside
the IDE.

> So, you can kinda see a n00bs frustration….
>
> I must be missing something big. Any tips (other than "try not to suck
> so much")?

Keep at it! After a while you'll have a ton of examples of how to do
things, and you just reuse your code. Ruby will pay you back ten times
what you put in. "The Ruby Way" has many many code examples too.


Les

Paul Van Delst

8/3/2006 7:55:00 PM

0

Nate Imaqaguy wrote:
> For starters, just do you know where Iâ??m coming from: I have little to
> no programming experience, except for some C and VB classes I took 6
> years ago, which I did fine in.
>
> My biggest hurdle getting started with ruby is finding which
> methods/classes/files to call upon for whatever the heck Iâ??m trying to
> accomplish.
>
> Iâ??m use to being able to perform a search, like in MSDN Library, using
> key words of something Iâ??m trying to perform. Then research results
> from there, and get pointed in the right direction (with explanations on
> what the feature does, and examples, etc).
>
> The editors also helped with showing the available methods, as I wrote
> the code.
>
> So, with ruby, Iâ??m using the SciTE editor (on WinXP), which doesnâ??t give
> method options as you go. Yeah, I know they are kinda like training
> wheels, but they help when youâ??re starting out.
>
> And I canâ??t really find any close equivalent to using something like an
> MSDN Library. The best thing someone has pointed me to so far is
> http://www.rub.... Which is cool and all, but itâ??s not really
> â??searchableâ?â??you kind of have to know what file/class/method to look up
> in the first place. And even if I find what I think Iâ??m looking for,
> the documentation is confusing to me. Sometimes there isnâ??t the
> slightest word as to what something does.

Oh man, you have just described my recent experiences to a T. Although it's not
searchable, the on-line version of the Programming Ruby "pickaxe" book,
http://www.rubycentra...
does do a pretty good job of listing just about everything built in on one page:
http://www.rubycentra.../builtins.html

After reading the paper version of the Pickaxe book, I bought a PDF version (only 10
bucks) of the Pickaxe (see http://www.pragmaticprog...) and keep it open on my
desktop - along with the builtin library page above, and the Ruby-doc.org page you
mentioned. I'm still in the hunting and gathering stage of ruby coding, but having those
three resources available -- along with Google -- as I'm editing ruby code has been
invaluable. In addition there are quite a number of webpages out there containing teaching
examples and code snippets.

Oh, and the Ruby Cookbook is a must have too (although it's a hefty beast at 900-odd
pages...and it doesn't look like it will be released as a PDF book anytime soon.)

> Someone told me about â??.methodsâ?, but that only works if youâ??re in an
> irb session, which I find painful to use because I have to type all my
> code in, line by line. I canâ??t even figure out how to paste each line
> of the code I already have. Inevitably I fat finger something and get
> mad.

I hear ya. On my Mac laptop, I haven't figured out how to get command line recall+traverse
(up/down,left/right arrows) yet in irb. Drives me nuts. But you can play around within a
regular source file rather than use irb directly. Sometimes I just play around at the end
of a source file, e.g.

-------- in file fruit.rb ---------
#!/usr/bin/env ruby
class Fruit
def initialize
@bananas=0
end
def pick
@bananas += 1
end
def eat
@bananas -= 1
end
def howmany?
@bananas
end
end

# Muck around test code for above classes follows.....
fruit=Fruit.new
puts "Picking some fruit...."
(1..10).each {|i| fruit.pick}
puts "Eating some fruit...."
fruit.eat
puts "I have #{fruit.howmany?} piece(s) of fruit left."
---------------------------------

And then simply do

$ ruby -w fruit.rb

on the command line or, in irb, use "require"

irb(main):001:0> require 'fruit'
Picking some fruit....
Eating some fruit....
I have 9 piece(s) of fruit left.
=> true

to see if the stuff after the "actual" code (e.g. classes, modules, whatnot) does what I
think it does. If not, I modify, save, and re-run.


Extremely low-tech .... but I'm having a ball. :o)

cheers,

paulv


--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545

Mat Schaffer

8/3/2006 8:10:00 PM

0


On Aug 3, 2006, at 2:05 PM, Nate Imaqaguy wrote:
> For starters, just do you know where I’m coming from: I have little to
> no programming experience, except for some C and VB classes I took 6
> years ago, which I did fine in.
>
> My biggest hurdle getting started with ruby is finding which
> methods/classes/files to call upon for whatever the heck I’m trying to
> accomplish.
>
> I’m use to being able to perform a search, like in MSDN Library, using
> key words of something I’m trying to perform. Then research results
> from there, and get pointed in the right direction (with
> explanations on
> what the feature does, and examples, etc).
>
> The editors also helped with showing the available methods, as I wrote
> the code.
>
> So, with ruby, I’m using the SciTE editor (on WinXP), which doesn’t
> give
> method options as you go. Yeah, I know they are kinda like training
> wheels, but they help when you’re starting out.
>
> And I can’t really find any close equivalent to using something
> like an
> MSDN Library. The best thing someone has pointed me to so far is
> http://www.rub.... Which is cool and all, but it’s not really
> “searchable”—you kind of have to know what file/class/method to
> look up
> in the first place. And even if I find what I think I’m looking for,
> the documentation is confusing to me. Sometimes there isn’t the
> slightest word as to what something does.
>
> Someone told me about “.methods”, but that only works if you’re in an
> irb session, which I find painful to use because I have to type all my
> code in, line by line. I can’t even figure out how to paste each line
> of the code I already have. Inevitably I fat finger something and get
> mad.
>
> So, you can kinda see a n00bs frustration….
>
> I must be missing something big. Any tips (other than “try not to
> suck
> so much”)?
>
> = )

I share your frustration. I have yet to find any really nice,
interactive ruby documentation. I think part of the problem is that
the core of the language isn't even fully documented. But ruby-
doc.org is doing a lot of work to fix this problem.

Contrary to a lot of people on this list, I don't recommend Pickaxe
for introduction. It is awesome reference, but I found it really dry
as an introductory text. If you have a good sense of humor and some
patience, I'd recommend The Poignant Guide http://poignant...
ruby/.

Then to get some early practice with the ideas, I'd recommend
rubyquiz.com. There's a lot of nice little exercises there with lots
of source code and analysis for each problem. (Note: download all
the solutions, as some of the older individual solutions reference
mailing list archives that are no longer available).

Finally, when you're stuck, ask a question here. It's one of the
nicest programming lists I've ever been on.
-Mat


Seth Thomas Rasmussen

8/3/2006 8:17:00 PM

0

Don't forget ri!

$ ri Array#each
$ ri Enumerable

etc.

:)

Nate Imaqaguy wrote:
> For starters, just do you know where I'm coming from: I have little to
> no programming experience, except for some C and VB classes I took 6
> years ago, which I did fine in.
>
> My biggest hurdle getting started with ruby is finding which
> methods/classes/files to call upon for whatever the heck I'm trying to
> accomplish.
>
> I'm use to being able to perform a search, like in MSDN Library, using
> key words of something I'm trying to perform. Then research results
> from there, and get pointed in the right direction (with explanations on
> what the feature does, and examples, etc).
>
> The editors also helped with showing the available methods, as I wrote
> the code.
>
> So, with ruby, I'm using the SciTE editor (on WinXP), which doesn't give
> method options as you go. Yeah, I know they are kinda like training
> wheels, but they help when you're starting out.
>
> And I can't really find any close equivalent to using something like an
> MSDN Library. The best thing someone has pointed me to so far is
> http://www.rub.... Which is cool and all, but it's not really
> "searchable"-you kind of have to know what file/class/method to look up
> in the first place. And even if I find what I think I'm looking for,
> the documentation is confusing to me. Sometimes there isn't the
> slightest word as to what something does.
>
> Someone told me about ".methods", but that only works if you're in an
> irb session, which I find painful to use because I have to type all my
> code in, line by line. I can't even figure out how to paste each line
> of the code I already have. Inevitably I fat finger something and get
> mad.
>
> So, you can kinda see a n00bs frustration....
>
> I must be missing something big. Any tips (other than "try not to suck
> so much")?
>
> = )
>
> --
> Posted via http://www.ruby-....

Bill Kelly

8/3/2006 8:32:00 PM

0

From: "Nate Imaqaguy" <breakingsoftware@gmail.com>
>
> Someone told me about â??.methodsâ?, but that only works if youâ??re in an
> irb session, which I find painful to use because I have to type all my
> code in, line by line. I canâ??t even figure out how to paste each line
> of the code I already have. Inevitably I fat finger something and get
> mad.

On Windows, I've found running irb as:

irb --noreadline

can provide more hassle-free support for line editing / copy / paste and
command history in irb.



Hope this helps,

Bill