[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

newbie confusion and dejection

Reg

4/13/2009 3:58:00 AM

Over the years I have taught myself to program in C, C++, and VB to
build apps to run in WIndows, along with the scripting languages
necessary to set up a website
I have built websites using PHP, Ajax, and MySql but am just a
hobbyist and my basic knowledge of how systems work is very patchy.
I have limited experience of linux, enough to get me by with what I
need to use SSH when necessary on my website's shared server.

Now, for my sins, I am trying to learn RoR.

I have no problem following the language tutorials but I am lost when
it comes actually running a ruby app or script in windows (or anywhere
else for that matter). I had been hoping to use RoR on my website.
I can create a Rails framework on the server but decided I needed to
learn more about Ruby before I did any more work there.

I have installed the following:
InstantRails
Cygwin

The Ruby directory has ruby.exe which opens a command line window and
rubyw.exe which does nothing when I click it.

I am using the Pragmatic Programmers Guide and Simply Rails2 by
Patrick Lenz as my learning tools.

I am wallowing about in irb and the Ruby console opened from the
Rails control panel playing about with classes etc and learning the
syntax of the language but achieving nothing else. The console seems
to be a very limited playground when it comes to trying out things
quickly. e.g. in irb I cannot paste anything into the console.
Am I missing something here?

When I learn a language I usually manage to cobble together a simple
hello world type of executable app or script and build on my mistakes
from there. but I cannot work out how to do this or get a ruby script
running. Given time I guess i will work it out but woud be grateful if
someone here could advise me what I should be doing next to master
ruby and RoR.

Thanks
Reg
13 Answers

Bill Kelly

4/13/2009 4:17:00 AM

0


From: "Reg" <reg@nospam.com>
>
> When I learn a language I usually manage to cobble together a simple
> hello world type of executable app or script and build on my mistakes
> from there. but I cannot work out how to do this or get a ruby script
> running.

I'm not trying to discourage you from learning Rails, but
you may be interested to know there are equally powerful
alternatives.

Take a look at how simple it is to get a "Hello, World"
app going in Ramaze:

http://ramaze.net/learn/getti...

I realize this just boils down to personal preference, but
I never liked the way Rails likes to generate a skeleton
of dozens of files when beginning a new app.

In contrast, frameworks like Ramaze let you start simple,
and add complexity when you decide you need it.


Regards,

Bill



John Maclean

4/13/2009 4:40:00 AM

0

2009/4/13 Bill Kelly <billk@cts.com>:
>
> From: "Reg" <reg@nospam.com>
>>
>> When I learn a language I usually manage to cobble together a simple
>> hello world type of executable app or script and build on my mistakes
>> from there. but I cannot work out how to do this or get a ruby script
>> running.
>
> I'm not trying to discourage you from learning Rails, but
> you may be interested to know there are equally powerful
> alternatives.
>
> Take a look at how simple it is to get a "Hello, World"
> app going in Ramaze:
>
> http://ramaze.net/learn/getti...
>
> I realize this just boils down to personal preference, but
> I never liked the way Rails likes to generate a skeleton
> of dozens of files when beginning a new app.
>
> In contrast, frameworks like Ramaze let you start simple,
> and add complexity when you decide you need it.
>
>
> Regards,
>
> Bill
>
>
>
>

This is going to sound silly but until I got into unit testing I could
never really think about what _I_ wanted to do but had to think about
__how__ to do it. Mike Clark has writen an excellent guide to unit
testing [0] and it's a bloody fast way to actually learn Ruby from the
ground up.

Before:
/me: OK. I can use ri --this and ri --that but now I am ri
Bored::shitless of all of this documentation. I want to start actually
writing stuff but keep having to think about how it's done.

after:
/me: kapow! shazaam. Now I can test what I know. I'll see where my
stuff goes wrong. Ah. So __that's__ how you use an array, huh? Take
that! kaplow! So that's what you mean by regexp? So I think that I can
get an IP address like this /\d+\d+\d+\d+/.

and I can now test bits of my code whilst I am thinking about what I want to do.

That make sense?

[0] http://clarkware.com/cgi/blosxom/Rub...

--
John Maclean
07739 171 531
MSc (DIC)

Timezone: GMT

Reg

4/13/2009 6:01:00 AM

0

On Sun, 12 Apr 2009 23:17:25 -0500, Bill Kelly <billk@cts.com> wrote:

>
>From: "Reg" <reg@nospam.com>
>>
>> When I learn a language I usually manage to cobble together a simple
>> hello world type of executable app or script and build on my mistakes
>> from there. but I cannot work out how to do this or get a ruby script
>> running.
>
>I'm not trying to discourage you from learning Rails, but
>you may be interested to know there are equally powerful
>alternatives.
>
>Take a look at how simple it is to get a "Hello, World"
>app going in Ramaze:
>
>http://ramaze.net/learn/getti...
>
>I realize this just boils down to personal preference, but
>I never liked the way Rails likes to generate a skeleton
>of dozens of files when beginning a new app.
>
>In contrast, frameworks like Ramaze let you start simple,
>and add complexity when you decide you need it.
>
>
>Regards,
>
>Bill
>
>

Thanks Bill - it's all grist to the mill

Reg

4/13/2009 6:42:00 AM

0

On Sun, 12 Apr 2009 23:40:08 -0500, john maclean <jayeola@gmail.com>
wrote:


>
>This is going to sound silly but until I got into unit testing I could
>never really think about what _I_ wanted to do but had to think about
>__how__ to do it. Mike Clark has writen an excellent guide to unit
>testing [0] and it's a bloody fast way to actually learn Ruby from the
>ground up.
>
>Before:
>/me: OK. I can use ri --this and ri --that but now I am ri
>Bored::shitless of all of this documentation. I want to start actually
>writing stuff but keep having to think about how it's done.
>
>after:
>/me: kapow! shazaam. Now I can test what I know. I'll see where my
>stuff goes wrong. Ah. So __that's__ how you use an array, huh? Take
>that! kaplow! So that's what you mean by regexp? So I think that I can
>get an IP address like this /\d+\d+\d+\d+/.
>
>and I can now test bits of my code whilst I am thinking about what I want to do.
>
>That make sense?
>
>[0] http://clarkware.com/cgi/blosxom/Rub...

It makes sense and did not sound silly, but these further questions
are going to sound silly and a bit pathetic too. I have been coddled
too long in programming environments like Macromedia Dreamweaver and
MS Visual Studio

1. Mike Clark says " Now, let's run the test." What is he running it
in? Is that the Ruby console?
2. Is there some way to write an app that will run as a windows
graphical user interface?
3. I am currently using the ConText editor. Is there an equivalent of
the MSVisualBasic IDE?
4. Should I be setting up a Ubuntu partition an learn Ruby in there?

Thanks for your patience
Reg

Dylan Evans

4/13/2009 6:47:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

On Mon, Apr 13, 2009 at 4:05 PM, Reg <reg@nospam.com> wrote:

> On Sun, 12 Apr 2009 23:17:25 -0500, Bill Kelly <billk@cts.com> wrote:
>
> >
> >
>
> Thanks Bill - it's all grist to the mill
>
> What?
You need to type your script up in a text editor, i hear notepad is great
for a starter. Then you need to save the file, as for example hello.rb .
Then you need to open up a terminal window and type 'ruby hello.rb'. Here
is your hello world in ruby;


puts 'Hello, World! God help us all!'


--
The UNIX system has a command, nice ... in order to be nice to the other
users. Nobody ever uses it." - Andrew S. Tanenbaum

Dylan Evans

4/13/2009 6:53:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

On Mon, Apr 13, 2009 at 4:45 PM, Reg <reg@nospam.com> wrote:

> On Sun, 12 Apr 2009 23:40:08 -0500, john maclean <jayeola@gmail.com>
> wrote:
>
>
> >
> >This is going to sound silly but until I got into unit testing I could
> >never really think about what _I_ wanted to do but had to think about
> >__how__ to do it. Mike Clark has writen an excellent guide to unit
> >testing [0] and it's a bloody fast way to actually learn Ruby from the
> >ground up.
> >
> >Before:
> >/me: OK. I can use ri --this and ri --that but now I am ri
> >Bored::shitless of all of this documentation. I want to start actually
> >writing stuff but keep having to think about how it's done.
> >
> >after:
> >/me: kapow! shazaam. Now I can test what I know. I'll see where my
> >stuff goes wrong. Ah. So __that's__ how you use an array, huh? Take
> >that! kaplow! So that's what you mean by regexp? So I think that I can
> >get an IP address like this /\d+\d+\d+\d+/.
> >
> >and I can now test bits of my code whilst I am thinking about what I want
> to do.
> >
> >That make sense?
> >
> >[0] http://clarkware.com/cgi/blosxom/Rub...
>
> It makes sense and did not sound silly, but these further questions
> are going to sound silly and a bit pathetic too. I have been coddled
> too long in programming environments like Macromedia Dreamweaver and
> MS Visual Studio
>
> 1. Mike Clark says " Now, let's run the test." What is he running it
> in? Is that the Ruby console?
> 2. Is there some way to write an app that will run as a windows
> graphical user interface?
> 3. I am currently using the ConText editor. Is there an equivalent of
> the MSVisualBasic IDE?
> 4. Should I be setting up a Ubuntu partition an learn Ruby in there?
>
> Thanks for your patience
> Reg
>
> Fair enough. I use netbeans with the ruby extensions, it is quite good for
managing a project. There are many ways to do gui work, apparently shoes is
a favorite but if you want a RAD you might be better off with gtk and glade
as a platform. You don't need to run ubuntu, actually it would probably just
confuse the issue for you since you have to learn a new environment to make
it useful.



--
The UNIX system has a command, nice ... in order to be nice to the other
users. Nobody ever uses it." - Andrew S. Tanenbaum

John Maclean

4/13/2009 7:07:00 AM

0

2009/4/13 Dylan Evans <dylan.star@gmail.com>:
> On Mon, Apr 13, 2009 at 4:05 PM, Reg <reg@nospam.com> wrote:
>
>> On Sun, 12 Apr 2009 23:17:25 -0500, Bill Kelly <billk@cts.com> wrote:
>>
>> >
>> >
>>
>> Thanks Bill - it's all grist to the mill
>>
>> What?
> You need to type your script up in a text editor, i hear notepad is great
> for a starter. Then you need to save the file, as for example hello.rb .
> Then you need to open up a terminal window and type 'ruby hello.rb'. =A0H=
ere
> is your hello world in ruby;
>
>
> puts 'Hello, World! God help us all!'
>
>
> --
> The UNIX system has a command, nice ... in order to be nice to the other
> users. Nobody ever uses it." - Andrew S. Tanenbaum
>

I wrote a simple code generator that would create a two files; a ruby
template file and a test_the_script.rb to test the script in that
file. Who cares what editor/IDE/OS I used? </insert your fave tool>
works for you and </emacs, vim, Debian/> works for me [a] ;-). Point
is that I wrote it in ruby and say `ruby generate_new_script.rb. to
generate the two files.

With unit testing in the file " test_generate_new_script.rb" I test
the script "generate_new_script.rb", so that I can check that my
thinking was right whilst I was writing the script.

Also, my knowledge base grows at the rate that _I_ learn as I write
more productive code. I hate notes, as they are easy to write. For me
tests are a nice way of saying to myself "STFU and __code__! Stop
collecting bookmarks, STFU and..."

I would strongly suggest that you spend sometime with that url [0].
You'll learn how __you__ learn Ruby.

[a] Disclaimer: Works For Me Technolgy is copyright of Jayeola.
Anything else that works is either completely beyond me or just pure
luck.

--=20
John Maclean
07739 171 531
MSc (DIC)

Timezone: GMT

Reg

4/13/2009 10:25:00 AM

0

On Mon, 13 Apr 2009 02:07:26 -0500, john maclean <jayeola@gmail.com>
wrote:

>I wrote a simple code generator that would create a two files; a ruby
>template file and a test_the_script.rb to test the script in that
>file. Who cares what editor/IDE/OS I used? </insert your fave tool>
>works for you and </emacs, vim, Debian/> works for me [a] ;-). Point
>is that I wrote it in ruby and say `ruby generate_new_script.rb. to
>generate the two files.
>
>With unit testing in the file " test_generate_new_script.rb" I test
>the script "generate_new_script.rb", so that I can check that my
>thinking was right whilst I was writing the script.
>
>Also, my knowledge base grows at the rate that _I_ learn as I write
>more productive code. I hate notes, as they are easy to write. For me
>tests are a nice way of saying to myself "STFU and __code__! Stop
>collecting bookmarks, STFU and..."
>
>I would strongly suggest that you spend sometime with that url [0].
>You'll learn how __you__ learn Ruby.
>
>[a] Disclaimer: Works For Me Technolgy is copyright of Jayeola.
>Anything else that works is either completely beyond me or just pure
>luck.



Thanks you guys.
Thus has all been a great help. I am getting on top of it now.
Reg

Mike Stephens

4/13/2009 10:35:00 AM

0

Reg wrote:
>
>
> I am using the Pragmatic Programmers Guide and Simply Rails2 by
> Patrick Lenz as my learning tools.
>
Rails isn't Ruby. I read the book "Agile Web Development with Rails" and
it seemed quite neat. But not my cup of tea.

If you're new to Ruby try something simpler like "Everyday Scripting
with Ruby". To play with the language, use something like Scite.

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

Mark S Bilk

4/13/2009 2:29:00 PM

0

Dylan Evans wrote:
> You need to type your script up in a text editor, i hear
> notepad is great for a starter. Then you need to save
> the file, as for example hello.rb .
> Then you need to open up a terminal window and type
> 'ruby hello.rb'.
> Here is your hello world in ruby;
> puts 'Hello, World! God help us all!'

You should make a directory on your disk for doing this,
e.g., c:/ruby . Tell the text editor to save the script
you write into that directory. When you open the terminal
window, change to that directory -- cd c:/ruby . (I haven't
used MS Windows for ten years, but I think that's right.)

You can test Ruby code without using that Unit Test framework.
Using one of the examples that was given for unit testing,
write the following code into a file called "foo.rb" in the
Ruby directory, and then type "ruby foo.rb" in the terminal
window (without the quotes) after cd'ing to that directory:

x = "Rick".index('t')
puts x.class
puts x

The interpreter will print this:

NilClass
nil

You've tested what happens when the "index" method is run
on the string "Rick" (and requested the index of a character
that isn't in the string). The result is assigned to a
variable x. First it prints the class of the result, and
then its value.

If you change the 't' to 'c' in the code, it prints this:

Fixnum
2

So the expression yields an integer whose value is the
place of the character in the string.

To me, this is simpler than creating a unit test for each
little bit of code you want to play with, and you don't
have to guess a value and put it into an "assert"
statement. You simply print out the value produced by
the code you're testing (which can be a single expression
or a large program) and also print its class. If "puts"
can't print out the value of some complex result object,
at least you know the class of the result, and can try
to find a way to print it out.

You are using one of the simplest and most powerful
debugging techniques -- putting print statements in
your code! Of course in a larger body of code you can
put multiple print statements to see what's going on.

One more suggestion: if you put this line in a Ruby file:

__END__

the interpreter will ignore everything that follows; won't
even syntax check it. So if you want to test lots of
pieces of code (which you will when learning Ruby), you
can move the ones you've already tested to a place in the
file after the __END__ line and save them there along with
a copy of what they printed out (use the mouse to copy and
paste it) and any comments you care to write. That way
you don't have to make a separate file for each test.

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