New to Ruby and Programming

Discussion in 'Ruby' started by Heath Fashina, Aug 16, 2006.

  1. 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/.
     
    Heath Fashina, Aug 16, 2006
    #1
    1. Advertising

  2. 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/articles/2006/01/05/code-as-a-data-type

    Hope it helps.

    James Edward Gray II
     
    James Edward Gray II, Aug 16, 2006
    #2
    1. Advertising

  3. Heath Fashina

    He Fa Guest

    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/articles/2006/01/05/code-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/.
     
    He Fa, Aug 16, 2006
    #3
  4. "He Fa" <> wrote in message
    news:...
    > 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
     
    Huw Collingbourne, Aug 16, 2006
    #4
  5. Heath Fashina

    He Fa Guest

    He Fa, Aug 16, 2006
    #5
  6. On 8/16/06, Huw Collingbourne <> wrote:
    >
    > "He Fa" <> wrote in message
    > news:...
    > > 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
     
    Simen Edvardsen, Aug 16, 2006
    #6
  7. Simen Edvardsen wrote:
    > On 8/16/06, Huw Collingbourne <> wrote:
    >>
    >> "He Fa" <> wrote in message
    >> news:...
    >> > 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
     
    Justin Collins, Aug 16, 2006
    #7
  8. "Simen Edvardsen" <> wrote in message
    news:...
    > 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
     
    Huw Collingbourne, Aug 16, 2006
    #8
  9. Heath Fashina

    He Fa Guest

    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/.
     
    He Fa, Aug 17, 2006
    #9
  10. Heath Fashina

    Matt Todd Guest

    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/
     
    Matt Todd, Aug 17, 2006
    #10
  11. Heath Fashina

    Daniel Baird Guest

    On 8/17/06, He Fa <> wrote:
    > The guy is nuts, but I'm enjoying the ride
    > http://poignantguide.net/ruby/


    you should watch what you say about _why.. I've heard he sends his
    winged monkeys after people who offend him.

    Or someone else does that. Maybe I read it somewhere. What's
    important here is that someone has got monkeys with wings. In a cage,
    I assume.

    --
    Daniel Baird
    http://tiddlyspot.com (free, effortless TiddlyWiki hosting)
    http://danielbaird.com (TiddlyW;nks! :: Whiteboard Koala :: Blog ::
    Things That Suck)
     
    Daniel Baird, Aug 17, 2006
    #11
  12. Heath Fashina

    Chad Perrin Guest

    On Thu, Aug 17, 2006 at 11:53:31AM +0900, Daniel Baird wrote:
    > On 8/17/06, He Fa <> wrote:
    > >The guy is nuts, but I'm enjoying the ride
    > >http://poignantguide.net/ruby/

    >
    > you should watch what you say about _why.. I've heard he sends his
    > winged monkeys after people who offend him.
    >
    > Or someone else does that. Maybe I read it somewhere. What's
    > important here is that someone has got monkeys with wings. In a cage,
    > I assume.


    Not just monkeys -- legions of mediocre code monkeys. They're in
    cubicles, not cages. Mostly, it's Java shops that have those, though.

    --
    CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ]
    print substr("Just another Perl hacker", 0, -2);
     
    Chad Perrin, Aug 17, 2006
    #12
  13. Heath Fashina

    Matt Todd Guest

    Fortunately, _Why is masterful enough to confuse them with strange
    Rubyisms like 10.method:)+).call(20) while obfuscating their mind-code
    and enslaving them to dwell on Javacs all day long. That and he feeds
    them yummy noodles.

    Hail javacs! I mean, _why! I wish you'd appear out of nowhere in
    Atlanta at a random coder BBQ! ;)

    M.T.
     
    Matt Todd, Aug 17, 2006
    #13
  14. Re: [AD] : Hooray RUBYROUC rolls

    On 8/16/06, Gus S Calabrese <> wrote:
    > The owner of the Oriental Theater and I signed on the dotted line
    > today for the unofficial add-on to the 2006 Ruby Conference.
    > See rubyrouc.com for more details.
    > Looking for presenters. Presentations can be via internet video
    > conferencing
    > link or via video on DVD. Of course being here live is the cat's
    > pajamas.


    I notice that you have not yet removed unnecessary attacks on members
    of the Ruby community from the website.

    Antagonizing the community will win you no friends.

    -austin
    --
    Austin Ziegler * * http://www.halostatue.ca/
    * * http://www.halostatue.ca/feed/
    *
     
    Austin Ziegler, Aug 18, 2006
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bill
    Replies:
    16
    Views:
    243
    David Ross
    Oct 17, 2004
  2. Will Shattuck

    New to Ruby and Programming

    Will Shattuck, Jan 2, 2006, in forum: Ruby
    Replies:
    31
    Views:
    271
    Frank Spychalski
    Jan 5, 2006
  3. Jon Kupe
    Replies:
    7
    Views:
    243
    Jon Kupe
    Sep 25, 2009
  4. Cassandra K.

    New to programming AND new to Ruby

    Cassandra K., Jan 31, 2011, in forum: Ruby
    Replies:
    10
    Views:
    298
    Clent Crumley
    Feb 4, 2011
  5. Replies:
    2
    Views:
    509
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page