Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > New to Ruby and Programming

Reply
Thread Tools

New to Ruby and Programming

 
 
Heath Fashina
Guest
Posts: n/a
 
      08-16-2006
Hi,

I am making yet another attempt at learning to program. I have a
little experience with QBASIC, RealBASIC, and Actionscript, but I am
pretty much a novice.

I am working my way through Chris Pine's tutorial but I'm stuck on Procs
and Blocks. I'm just not getting the last half of the chapter.

http://pine.fm/LearnToProgram/

Any guidance or detail explanation would be appreciated

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

 
Reply With Quote
 
 
 
 
James Edward Gray II
Guest
Posts: n/a
 
      08-16-2006
On Aug 15, 2006, at 7:06 PM, Heath Fashina wrote:

> Hi,
>
> I am making yet another attempt at learning to program. I have a
> little experience with QBASIC, RealBASIC, and Actionscript, but I am
> pretty much a novice.
>
> I am working my way through Chris Pine's tutorial but I'm stuck on
> Procs
> and Blocks. I'm just not getting the last half of the chapter.
>
> http://pine.fm/LearnToProgram/
>
> Any guidance or detail explanation would be appreciated


I wrote a blog post on this subject a while back that might at least
give you another point of view:

http://blog.grayproductions.net/arti...as-a-data-type

Hope it helps.

James Edward Gray II


 
Reply With Quote
 
 
 
 
He Fa
Guest
Posts: n/a
 
      08-16-2006
James Gray wrote:
> On Aug 15, 2006, at 7:06 PM, Heath Fashina wrote:
>
>> http://pine.fm/LearnToProgram/
>>
>> Any guidance or detail explanation would be appreciated

>
> I wrote a blog post on this subject a while back that might at least
> give you another point of view:
>
> http://blog.grayproductions.net/arti...as-a-data-type
>
> Hope it helps.
>
> James Edward Gray II


I have very limited knowledge with databases (i.e. filemaker pro and
some Access). I decided to just press on with my loose grasp of procs
and blocks and dive into:

"Programming Ruby:The Pragmatic Programmer's Guide, First Edition (*)

Hopefully, it'll just hit me or I'll have to find a new hobby


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

 
Reply With Quote
 
Huw Collingbourne
Guest
Posts: n/a
 
      08-16-2006

"He Fa" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed). ..
> James Gray wrote:
> I decided to just press on with my loose grasp of procs
> and blocks and dive into:
>
> "Programming Ruby:The Pragmatic Programmer's Guide, First Edition (*)
>
> Hopefully, it'll just hit me or I'll have to find a new hobby



I suspect you may be getting a bit too obsessive about those darn' blocks
and procs. While blocks can be useful for all kinds of things, they are not
'central' to programming in Ruby. Some Ruby programmers tend to get a bit
obsessive about blocks, procs, lambda functions and the like. If you find
this stuff baffling (and unless you already have experience of a language
such as Smalltalk or Scheme in which blocks are a 'natural' part of the
language), they may initially seem very baffling indeed, my advice would be
to use blocks only where they are absolutely required - namely, for
iterating over collections of things as when, for example, iterating over
the items in an array using the each() method.

I wouldn't worry at all about using blocks as 'nameless functions' or
passing and 'yielding' them. These can be useful in certain circumstances
but then again, you could spend a lifetime doing perfectly productive
programming in Ruby without ever doing any of those things

You may perhaps find my book, The Little Book Of Ruby, of some help. This is
a free PDF book which you can download from: www.sapphiresteel.com

While my book covers most of the essentials of Ruby - including things that
often stump newcomers (blocks, mixins etc.) I've tried to keep restrict it
to the essential details; you can also download all the source code for all
the sample programs (personally, it's my feeling that programming topics are
often easier to understand when you can try them out for yourself).

best wishes
Huw Collingbourne

http://www.sapphiresteel.com
Ruby Programming In Visual Studio 2005


 
Reply With Quote
 
He Fa
Guest
Posts: n/a
 
      08-16-2006
Hey Thanks,

I will definately check that out!

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

 
Reply With Quote
 
Simen Edvardsen
Guest
Posts: n/a
 
      08-16-2006
On 8/16/06, Huw Collingbourne <(E-Mail Removed)> wrote:
>
> "He Fa" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed). ..
> > James Gray wrote:
> > I decided to just press on with my loose grasp of procs
> > and blocks and dive into:
> >
> > "Programming Ruby:The Pragmatic Programmer's Guide, First Edition (*)
> >
> > Hopefully, it'll just hit me or I'll have to find a new hobby

>
>
> I suspect you may be getting a bit too obsessive about those darn' blocks
> and procs. While blocks can be useful for all kinds of things, they are not
> 'central' to programming in Ruby. Some Ruby programmers tend to get a bit
> obsessive about blocks, procs, lambda functions and the like. If you find
> this stuff baffling (and unless you already have experience of a language
> such as Smalltalk or Scheme in which blocks are a 'natural' part of the
> language), they may initially seem very baffling indeed, my advice would be
> to use blocks only where they are absolutely required - namely, for
> iterating over collections of things as when, for example, iterating over
> the items in an array using the each() method.
>


Ruby's standard library is filled with methods that (often optionally)
take blocks as arguments. Ignoring them isn't gonna do you any good. A
closure is a function that remembers the environment it was defined
in, and if you don't understand the concept of a function, programming
is not for you.

> I wouldn't worry at all about using blocks as 'nameless functions' or
> passing and 'yielding' them. These can be useful in certain circumstances
> but then again, you could spend a lifetime doing perfectly productive
> programming in Ruby without ever doing any of those things
>


Ignoring closures, which are extensively used within Ruby's standard
library and a large part in what makes the language so good for many
tasks, is not going to do you any good at all.

> You may perhaps find my book, The Little Book Of Ruby, of some help. This is
> a free PDF book which you can download from: www.sapphiresteel.com
>
> While my book covers most of the essentials of Ruby - including things that
> often stump newcomers (blocks, mixins etc.) I've tried to keep restrict it
> to the essential details; you can also download all the source code for all
> the sample programs (personally, it's my feeling that programming topics are
> often easier to understand when you can try them out for yourself).
>
> best wishes
> Huw Collingbourne
>
> http://www.sapphiresteel.com
> Ruby Programming In Visual Studio 2005
>
>
>
>



--
- Simen

 
Reply With Quote
 
Justin Collins
Guest
Posts: n/a
 
      08-16-2006
Simen Edvardsen wrote:
> On 8/16/06, Huw Collingbourne <(E-Mail Removed)> wrote:
>>
>> "He Fa" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed). ..
>> > James Gray wrote:
>> > I decided to just press on with my loose grasp of procs
>> > and blocks and dive into:
>> >
>> > "Programming Ruby:The Pragmatic Programmer's Guide, First Edition (*)
>> >
>> > Hopefully, it'll just hit me or I'll have to find a new hobby

>>
>>
>> I suspect you may be getting a bit too obsessive about those darn'
>> blocks
>> and procs. While blocks can be useful for all kinds of things, they
>> are not
>> 'central' to programming in Ruby. Some Ruby programmers tend to get a
>> bit
>> obsessive about blocks, procs, lambda functions and the like. If you
>> find
>> this stuff baffling (and unless you already have experience of a
>> language
>> such as Smalltalk or Scheme in which blocks are a 'natural' part of the
>> language), they may initially seem very baffling indeed, my advice
>> would be
>> to use blocks only where they are absolutely required - namely, for
>> iterating over collections of things as when, for example, iterating
>> over
>> the items in an array using the each() method.
>>

>
> Ruby's standard library is filled with methods that (often optionally)
> take blocks as arguments. Ignoring them isn't gonna do you any good. A
> closure is a function that remembers the environment it was defined
> in, and if you don't understand the concept of a function, programming
> is not for you.
>
>> I wouldn't worry at all about using blocks as 'nameless functions' or
>> passing and 'yielding' them. These can be useful in certain
>> circumstances
>> but then again, you could spend a lifetime doing perfectly productive
>> programming in Ruby without ever doing any of those things
>>

>
> Ignoring closures, which are extensively used within Ruby's standard
> library and a large part in what makes the language so good for many
> tasks, is not going to do you any good at all.


Perhaps not, but it's like that advice they give for taking tests...if
you find yourself getting hung up on a particular question, skip it and
come back to it later.
Except, you have much more time to skip blocks/closures for now and come
back to them later than problems on a test.
If it doesn't make sense now, get familiar with other parts of Ruby and
then come back to blocks, if it's getting frustrating.

-Justin


 
Reply With Quote
 
Huw Collingbourne
Guest
Posts: n/a
 
      08-16-2006

"Simen Edvardsen" <(E-Mail Removed)> wrote in message
news:77f44b300608161450y6d00a4b2yf0f366b730f6a570@ mail.gmail.com...
> if you don't understand the concept of a function, programming
> is not for you.
>


I would agree that the concept of a function (or method) is essential. I
don't agree that a beginner should be required to understand (or attempt to
use) blocks to any great extent beyond their role in iteration.

best wishes
Huw Collingbourne

http://www.sapphiresteel.com
Ruby Programming In Visual Studio 2005


 
Reply With Quote
 
He Fa
Guest
Posts: n/a
 
      08-16-2006
Simen Edvardsen wrote:
>A closure is a function that remembers the environment it was defined
> in, and if you don't understand the concept of a function, programming
> is not for you.
>



Fortunately, I do understand functions. I tend to understand most
things when explained thoroughly and using plain english. Or in the
case of http://poignantguide.net/ruby/ using oddball stories mixed
with tidbits of Ruby code.

The guy is nuts, but I'm enjoying the ride

http://poignantguide.net/ruby/

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

 
Reply With Quote
 
Matt Todd
Guest
Posts: n/a
 
      08-17-2006
Whether it is completely correct or not, I like to look at blocks as
little functions that I pass to another function as an argument, just
like I'd pass it a number or another object.

The distinction, though, is how that block of code is called, and that
that block of code can still access the variables you have laying
around where that block of code was called. It's like rewriting part
of the insides of another function!

As I said, the details are a bit more, well, detailed, and tricky,
too, but, as a very simple explaination, it works.

Now, as a way to get more familiar with it, I'd definitily check out
the Poignant Guide[1] and also _Why[2]'s TryRuby[3] interactive
walkthrough.

M.T.

1. http://poignantguide.net/
2. http://redhanded.hobix.com/
3. http://tryruby.hobix.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
New to programming AND new to Ruby Cassandra K. Ruby 10 02-04-2011 08:07 PM
New to Ruby, New to Programming. Jon Kupe Ruby 7 09-25-2009 02:35 AM
Ruby and Contract Programming (was Ruby vs. Ada) Robert Dober Ruby 4 04-22-2008 07:35 PM
#!/usr/bin/ruby , #!/usr/bin/ruby -w , #!/usr/bin/ruby -T?, #!/usr/bin/ruby -T1... anne001 Ruby 1 04-23-2006 03:02 PM
Possible training classes for Ruby programming and for Ruby on Rails Curt Hibbs Ruby 0 05-31-2005 06:39 PM



Advertisments