Iâ?m having a hard time learning ruby

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.ruby-doc.org/. 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�)?

= )

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.

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


Ramsey [email protected]
GPG fingerprint = 0E28 4713 428E AC4E AE05 A4A6 D70B 321D 7188 3AD0

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 Fri, Aug 04, 2006 at 03:05:41AM +0900, Nate I. 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.

On 8/3/06, Nate I. [email protected] wrote:

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 F.'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.ruby-doc.org/. 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

My recommendation is: go to

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

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 :slight_smile:

Regards, Morton

Nate I. wrote:

from there, and get pointed in the right direction (with explanations on
MSDN Library. The best thing someone has pointed me to so far is
http://www.ruby-doc.org/. 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.rubycentral.com/book
does do a pretty good job of listing just about everything built in on
one page:
http://www.rubycentral.com/book/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.pragmaticprogrammer.com) 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

Don’t forget ri!

$ ri Array#each
$ ri Enumerable

etc.

:slight_smile:

On Aug 3, 2006, at 2:05 PM, Nate I. wrote:

from there, and get pointed in the right direction (with

Someone told me about ?.methods?, but that only works if you?re in an

= )

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://poignantguide.net/
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

Cool; thanks for all the feedback–excellent info.

I especially like the idea of searching the digital books to get the
MSDN effect. I hadn’t thought about that.

-nate

From: “Nate I.” [email protected]

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

Mat S. wrote:

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.

I’m always glad to hear when someone finds the site helpful. But I do
want to make clear that the actual documentation comes from a relatively
small number of very smart, very dedicated Rubyists who volunteer to add
and correct the documentation.

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://poignantguide.net/ ruby/.

I’d highly recommend David A. Black’s Ruby for Rails. Doesn’t matter if
you know or use Rails; you can look at the references to Rails as just
an example application used to illustrate essential Ruby language
features. (Of course, if you do use Rails then the book is perhaps even
more useful.)


James B.

“The greatest obstacle to discovery is not ignorance, but the illusion
of knowledge.”

  • D. Boorstin

I especially like the idea of searching the digital books to
get the MSDN effect. I hadn’t thought about that.

And as for method completion, I believe Komodo will do that
(www.activestate.com).

  • Mark.

But, really, with all of this frustration… it’s better than the
frustrations just about anything else will give you… :slight_smile:

M.T.

On 8/3/06, Nate I. [email protected] wrote:

Also as you come from a Win32 background, rdoc (the tool used to
generate much of the API docs for Ruby), can create (if you have
HTMLHelp) chm files, which might feel very comfortable as well.

pth

Seth Thomas R. wrote:

Don’t forget ri!

$ ri Array#each
$ ri Enumerable

BTW, do other folks get this i_formatter.rb warning when they use ri:

lnx:local/ruby-1.8.4 : ri Array#each
/usr/local/lib/ruby/1.8/rdoc/ri/ri_formatter.rb:46: warning: (…)
interpreted as grouped
expression

…followed by the actual rdoc output…

?? I get it on linux and mac osx

cheers,

paulv

hope some of these help

http://www.ruby-doc.org/
Documentation

http://ruby.cenophobie.com/rubycheat.php
The ruby cheat sheet - should go through this one

http://www.zenspider.com/Languages/Ruby/QuickRef.html
the ruby quick ref

http://en.wikibooks.org/wiki/Programming:Ruby
wiki book if that helps

http://www.artima.com//rubycs/articles/patterns_sexp_dsls.html
stuff you might want to read latter on…

If you are going to code really seriously might want some theoretical
stuff
about general coding:
http://mitpress.mit.edu/sicp/full-text/book/book.html

The links say it all
http://www.techbooksforfree.com/
http://www.techtoolblog.com/archives/195-free-online-programming-books

Hope that helps

Harish

On 8/3/06, Nate I. [email protected] wrote:

Cool; thanks for all the feedback–excellent info.

I especially like the idea of searching the digital books to get the
MSDN effect. I hadn’t thought about that.

Something else that helps with that is Google Desktop. It can index
PDF files so you can do a more fuzzy search than the strict one you
can do in Abobe Reader.

Though PDF’s protected with DRM can probably defeat Google Desktop,
which is just another reason to be wary of them.

Les

“Nate I.” [email protected] wrote in message
news:[email protected]

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.

This is, perhaps, your biggest hurdle, in my opinion.  As much as I 

love
Ruby, I’ve always been suspicious of Ruby as a first language. It’s so
free
and lacks any kind of hand-holding, which is a breath of fresh air for
experienced programmers but can be a hurdle for novices…

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.

However, if this is your only problem then you're probably a more

competent programmer than you let on. If that’s the case, Paul’s
suggestion
of this reference will be valuable to you:

http://www.rubycentral.com/book/builtins.html

It's not exactly searchable but, if you know what kind of behaviour

you’re looking for, you can probably simply guess what you’re looking
for
and be right. For instance, if you’re looking for string concatenation,
then you can guess that it will be a method of the “String” class and
then,
look at all the methods of that class for something that might suggest
concatenation. You can get quite far doing simply this…

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'm an experienced MS Windows developer and I am, thus, intimately

familiar with both the Win32 API and the MSDN Library and, yet, despite
all
this, I’ve never found the search tool (as you’ve described it) useful,
so I
can’t help you here.

I don't know if this is considered rude or not but, since the 

Pickaxe
book is available online at:

http://www.rubycentral.com/book/

...you could simply suck down the entire site and perform your 

search on
the HTML, all for free. Again, I don’t know how the community feels
about
you downloading the entire online “book,” so my apologies if this is
considered rude…

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.ruby-doc.org/. 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.

Embarrassingly enough, I wasn't aware of ruby-doc.org before and, 

now
that I’m looking at it, it looks like an excellenet reference, which
doesn’t
bode well for the advice I have given you up til now. I haven’t
scrutinized
it but ,judging from the documentation for class “Array,” it looks
rather
thorough. Are you looking up more obscure functionality?

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.

The "methods" method works anywhere in Ruby but it is most useful in 

an
IRB session.
I’m unsure why you want to type in your entire program into IRB.
You
probably just want to type in relevant situations to test Ruby’s
behaviour,
such as operator precedence or regex behaviour.
If you want to look at all the methods of a class, you simply need
to
create an object of said class and call the “methods” method, perahps
followed by the “sort” method which can help you find what you’re lookig
for…

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 assure you, we're all familiar with frustration, even if it's not 

over
the same things.
Good luck to you and I hope you make progress!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs