[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

My Thought on the "Pickaxe book" (from a Ruby novice

John Maclean

1/19/2006 12:02:00 PM

Chaps,

Ruby seems like a great language and the book's good too. However a novice like me won't be able to appreciate *.rb when there's soooo many examples of "there's more than one way to do it". I learn pretty quickly and even faster when I can understand a concept, test it and see that it works. How do you other novices feel about this?

This is not a rant/flame/plug my book/some other language is better posting ;)

--
John Maclean
MSc (DIC)
07739 171 531



35 Answers

Jules

1/19/2006 12:15:00 PM

0

John Maclean wrote:
> Chaps,
>
> Ruby seems like a great language and the book's good too. However a
> novice like me won't be able to appreciate *.rb when there's soooo many
> examples of "there's more than one way to do it". I learn pretty quickly
> and even faster when I can understand a concept, test it and see that it
> works. How do you other novices feel about this?
>
> This is not a rant/flame/plug my book/some other language is better
> posting ;)

I think I do not understand what you mean...

If you mean that you have to create a new *.rb file to test something:
use IRB.
IRB is really good for testing. Just type: "irb" in a console.

Jules

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


Doug Bromley

1/19/2006 12:26:00 PM

0

I think what John is saying is that in the other languages he's used
there is a single way of doing something and once you've learnt the
concept - thats it. Done.
However, in the Ruby language there's multiple ways of doing the same
thing and having every example of a concept thrown at you can be a
little overwhelming and leave you feeling a little lost, asking - Why
not just have one way?!

Its a common frustration of people who've come from other programming
backgrounds besides Perl, etc.


On 1/19/06, John Maclean <info@jayeola.org> wrote:
> Chaps,
>
> Ruby seems like a great language and the book's good too. However a novice like me won't be able to appreciate *.rb when there's soooo many examples of "there's more than one way to do it". I learn pretty quickly and even faster when I can understand a concept, test it and see that it works. How do you other novices feel about this?
>
> This is not a rant/flame/plug my book/some other language is better posting ;)
>
> --
> John Maclean
> MSc (DIC)
> 07739 171 531
>
>
>


--
Wisdom is the reward you get for a lifetime of listening when you'd
have preferred to talk.


John Maclean

1/19/2006 12:40:00 PM

0

Thanks Doug. More concise and articulate that I ever could be.

On Thu, 19 Jan 2006 21:25:46 +0900
Doug Bromley <doug.bromley@gmail.com> wrote:

> I think what John is saying is that in the other languages he's used
> there is a single way of doing something and once you've learnt the
> concept - thats it. Done.
> However, in the Ruby language there's multiple ways of doing the same
> thing and having every example of a concept thrown at you can be a
> little overwhelming and leave you feeling a little lost, asking - Why
> not just have one way?!
>
> Its a common frustration of people who've come from other programming
> backgrounds besides Perl, etc.
>
>
> On 1/19/06, John Maclean <info@jayeola.org> wrote:
> > Chaps,
> >
> > Ruby seems like a great language and the book's good too. However a novice like me won't be able to appreciate *.rb when there's soooo many examples of "there's more than one way to do it". I learn pretty quickly and even faster when I can understand a concept, test it and see that it works. How do you other novices feel about this?
> >
> > This is not a rant/flame/plug my book/some other language is better posting ;)
> >
> > --
> > John Maclean
> > MSc (DIC)
> > 07739 171 531
> >
> >
> >
>
>
> --
> Wisdom is the reward you get for a lifetime of listening when you'd
> have preferred to talk.
>
>
>


--
John Maclean
MSc (DIC)
07739 171 531



Ken

1/19/2006 2:24:00 PM

0

John, pick out the way to do something that seems most natural to you
and get familiar with that. Then ignore the rest. I think Ruby's "more
than one way to do it" was intended as a blessing, not a burden.


John Maclean wrote:
> Thanks Doug. More concise and articulate that I ever could be.
>
> On Thu, 19 Jan 2006 21:25:46 +0900


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


Mark Volkmann

1/19/2006 3:44:00 PM

0

On 1/19/06, Kenneth Collins <pine29@myfastmail.com> wrote:
> John, pick out the way to do something that seems most natural to you
> and get familiar with that. Then ignore the rest. I think Ruby's "more
> than one way to do it" was intended as a blessing, not a burden.

That's not really good enough though. I you ever have a need to read
Ruby code that someone else wrote, you'll have to understand every way
to do something. I love Ruby, but I'm not yet a fan of having many
ways to do something unless there are cases where each possible
approach is better than the others.

A particular thing I dislike is synonyms for methods in the built-in
classes. Sure I can choose to use the method name that makes the most
sense to me, but I still have to be aware of all the synonyms so I can
read code that others wrote.

--
R. Mark Volkmann
Partner, Object Computing, Inc.


james_b

1/19/2006 4:03:00 PM

0

Mark Volkmann wrote:
> On 1/19/06, Kenneth Collins <pine29@myfastmail.com> wrote:
>
>>John, pick out the way to do something that seems most natural to you
>>and get familiar with that. Then ignore the rest. I think Ruby's "more
>>than one way to do it" was intended as a blessing, not a burden.
>
>
> That's not really good enough though. I you ever have a need to read
> Ruby code that someone else wrote, you'll have to understand every way
> to do something. I love Ruby, but I'm not yet a fan of having many
> ways to do something unless there are cases where each possible
> approach is better than the others.

How many different ways are there for doing various tasks? 2? 3?

For how many fundamental operations?

Do the variations follow some general pattern or principle?

Can anyone offer examples of multiple ways of doing something
fundamental, and point out where it may be confusing?

I've read complaints about Ruby allowing both if/then and unless/then,
as well as the option to put the test either at the start or end of the
expression. I don't find this a remarkably complex idea, but perhaps if
it is poorly introduced then the options may seem arbitrary.


>
> A particular thing I dislike is synonyms for methods in the built-in
> classes. Sure I can choose to use the method name that makes the most
> sense to me, but I still have to be aware of all the synonyms so I can
> read code that others wrote.


In the long run I'd rather have to periodically go to ri or ruby-doc to
learn something if it means I can choose message names that better
express my intentions.


James
--

http://www.ru... - Ruby Help & Documentation
http://www.artima.c... - The Journal By & For Rubyists
http://www.rub... - The Ruby Store for Ruby Stuff
http://www.jame... - Playing with Better Toys
http://www.30seco... - Building Better Tools


Ara.T.Howard

1/19/2006 4:42:00 PM

0

Yohanes Santoso

1/19/2006 5:00:00 PM

0

ara.t.howard@noaa.gov writes:

> On Thu, 19 Jan 2006, John Maclean wrote:
>
>> Chaps,
>>
>> Ruby seems like a great language and the book's good too. However a novice
>> like me won't be able to appreciate *.rb when there's soooo many examples of
>> "there's more than one way to do it". I learn pretty quickly and even faster
>> when I can understand a concept, test it and see that it works. How do you
>> other novices feel about this?
>>
>> This is not a rant/flame/plug my book/some other language is better posting ;)
>
> think of it as learning to drive a short throw six-speed transmission - harder
> at first - so much faster once you've got it. ;-)

How true,

It took me sometimes learning to drive a machine of mine with such
transmission. Now I'm much faster.

YS.
1992 CBRF2 -- what? you're expecting a Ferrari?



Mark Volkmann

1/19/2006 6:41:00 PM

0

On 1/19/06, James Britt <james_b@neurogami.com> wrote:
> Mark Volkmann wrote:
> > On 1/19/06, Kenneth Collins <pine29@myfastmail.com> wrote:
> >
> >>John, pick out the way to do something that seems most natural to you
> >>and get familiar with that. Then ignore the rest. I think Ruby's "more
> >>than one way to do it" was intended as a blessing, not a burden.
> >
> >
> > That's not really good enough though. I you ever have a need to read
> > Ruby code that someone else wrote, you'll have to understand every way
> > to do something. I love Ruby, but I'm not yet a fan of having many
> > ways to do something unless there are cases where each possible
> > approach is better than the others.
>
> How many different ways are there for doing various tasks? 2? 3?
>
> For how many fundamental operations?
>
> Do the variations follow some general pattern or principle?
>
> Can anyone offer examples of multiple ways of doing something
> fundamental, and point out where it may be confusing?

I guess I'm more annoyed by synonyms than multiple syntax approaches
because there don't seem to be too many of those.

> I've read complaints about Ruby allowing both if/then and unless/then,
> as well as the option to put the test either at the start or end of the
> expression. I don't find this a remarkably complex idea, but perhaps if
> it is poorly introduced then the options may seem arbitrary.
>
> > A particular thing I dislike is synonyms for methods in the built-in
> > classes. Sure I can choose to use the method name that makes the most
> > sense to me, but I still have to be aware of all the synonyms so I can
> > read code that others wrote.
>
> In the long run I'd rather have to periodically go to ri or ruby-doc to
> learn something if it means I can choose message names that better
> express my intentions.

I guess that's the part I don't get. In the majority the cases, I
don't see how choosing a particular synonym better expresses the
intention.

For example, in the Hash class, has_key? = include? = key? = member?
When I see include? and member? it's not immediately obvious to me
whether they test whether a given object is present as a key or a
value. has_key? and key? are more clear and I don't see a benefit to
having both of them.

That may be the best example. Here are some others.

Enumerable:
collect = map
entries = to_a
detect = find
member? = include?
find_all = select

Hash:
store = []=
merge! = update
has_value? = value?

Integer:
next = succ

IO:
pos = tell

Kernel:
fail = raise
format = sprintf

String
next = succ
next! = succ!

Thread
fork = start
exit = kill = terminate

In most of these cases you could argue that one would guess that they
are synonyms. Still I think many will have nagging doubts about
whether there are subtle differences and decide to take the time to
look up their definitions. For example, is Thread.kill really the same
as Thread.exit? kill sounds so ominous. Maybe there is a small
difference, you'll think to yourself. Verifying these things makes it
take longer to read code, which is really the main point of my rant.

--
R. Mark Volkmann
Partner, Object Computing, Inc.


James Gray

1/19/2006 7:07:00 PM

0

On Jan 19, 2006, at 12:40 PM, Mark Volkmann wrote:

> For example, in the Hash class, has_key? = include? = key? = member?
> When I see include? and member? it's not immediately obvious to me
> whether they test whether a given object is present as a key or a
> value. has_key? and key? are more clear and I don't see a benefit to
> having both of them.

That's interesting. I always use include?() so it doesn't matter if
I'm dealing with a Hash or an Array. ;)

I am sure glad we can both have it our way.

James Edward Gray II