Forum: Ruby Golfing (was Re: Chomping and stomping)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jacob F. (Guest)
on 2006-02-02 23:21
(Received via mailing list)
On 2/2/06, William J. <removed_email_address@domain.invalid> wrote:
> code before they post are always willing to indulge in that pastime.
Let me clarify.

 * I don't mind you golfing on the list/newsgroup.
 * I don't mind you golfing about this task.

What I do mind is threads that were not intended as golfing threads
being hijacked into a golf contest. If I were the OP and posted a
question, then later saw a new post in the thread stemming from that
question, I'd expect useful input or discussion regarding my question.
I am especially touchy about this when golfing replies are posted in
response to a newbie question. While golf can be fun, we don't want
the newbie to get the wrong idea that the techniques used in the golf
are representative of how the code *should* be written.

If you feel the desire to golf, please at least rethread it by
changing (at minimum) the subject line.

Jacob F.

PS. And regarding "those who enjoy programming and who test their code
before they post are always willing to indulge in that pastime". I
*usually* check the code I post, you were fortunate to catch me at a
time when my mind was on other things and I was pressed for time.
Since I am not willing to indulge in golf, I must not enjoy
programming then. Dang, and I thought I liked it...
Ezra Z. (Guest)
on 2006-02-03 02:04
(Received via mailing list)
On Feb 2, 2006, at 1:20 PM, Jacob F. wrote:

>> contest, since those who enjoy programming and who test their
> question, I'd expect useful input or discussion regarding my question.
> PS. And regarding "those who enjoy programming and who test their code
> before they post are always willing to indulge in that pastime". I
> *usually* check the code I post, you were fortunate to catch me at a
> time when my mind was on other things and I was pressed for time.
> Since I am not willing to indulge in golf, I must not enjoy
> programming then. Dang, and I thought I liked it...
>

Plus the original poster specifically asked about how to get rid of
$_ in the code, not how to add more of it.

-Ezra
William J. (Guest)
on 2006-02-03 13:29
(Received via mailing list)
Jacob F. wrote:
> > contest, since those who enjoy programming and who test their
> > code before they post are always willing to indulge in that pastime.
>
> Let me clarify.
>
>  * I don't mind you golfing on the list/newsgroup.
>  * I don't mind you golfing about this task.

What egregious arrogance!  Let me clarify.  What you mind
doesn't matter.

>
> What I do mind is threads that were not intended as golfing threads
> being hijacked into a golf contest.

I'm a wicked hijacker.  I know I am because Mr. Fugal told me so.

>                                 If I were the OP and posted a
> question, then later saw a new post in the thread stemming from that
> question, I'd expect useful input or discussion regarding my question.
> I am especially touchy about this when golfing replies are posted in
> response to a newbie question. While golf can be fun, we don't want
> the newbie to get the wrong idea that the techniques used in the golf
> are representative of how the code *should* be written.

If you didn't want to mislead the newbie, why did you say:
'String#chomp! is a "destructive" operation. This means that it acts in
place on its receiver and, in this case, returns nil.'

If you didn't want to mislead the newbie, why did you post this:

def chomper
    xx = gets.chomp
    until xx == "qq"
      puts "hit me with a squirell!"
      xx
    end
end

puts chomper

Even if there was a way for the loop to terminate, xx would not
be returned.  It has to be moved outside of the loop.
Extremely misleading.  Extremely confusing to a newbie.
(Of course, Mr. Fugal doesn't mind that, since whatever he does
is o.k. with him.)  And it was extremely arrogant to post untested
code.

Furthermore, it was extremely rude as well as incredibly arrogant
to assert falsely that my code wouldn't work correctly when
you had not condescended to test it.

Much better than the above code is:

def chomper
  puts "Hit me!"  while gets.chomp! != "qq"
  $_
end

It is superior in three ways.
1. It is correct.
2. It is clearer.
3. It is shorter.

Naturally, Mr. Fugal's arrogance compels him to dismiss
my version by using the term "golf", hoping that you will
assume that "golf" is a Bad Thing.

Newbies, don't be afraid of $_.  Matz didn't include it in Ruby
in order to tempt the unwary into becoming "evil golfers".
He included it because it is useful.  Of course, Mr. Fugal's
arrogance leads him to believe that his opinion outweighs
Matz's.


> PS. And regarding "those who enjoy programming and who test their code
> before they post are always willing to indulge in that pastime". I
> *usually* check the code I post, you were fortunate to catch me at a
> time when my mind was on other things and I was pressed for time.

Why would that make me fortunate?  Oh, I get it now!  Seeing a human
make an error is an everyday occurance, but witnessing a goof by a god
is special.
Jacob F. (Guest)
on 2006-02-03 19:31
(Received via mailing list)
On 2/3/06, William J. <removed_email_address@domain.invalid> wrote:
> Jacob F. wrote:
> > Let me clarify.
> >
> >  * I don't mind you golfing on the list/newsgroup.
> >  * I don't mind you golfing about this task.
>
> What egregious arrogance!  Let me clarify.  What you mind
> doesn't matter.

I didn't say it did. I was just clarifying *my opinion*. When I asked
for no golfing in that thread, it was because in *my opinion* it was
off-topic for that thread. When you called me on the statement, I
thought I better clarify *my opinion*, hence I clarified while using
the pronoun "I". You can discard *my opinion* and I don't care. Don't
call me arrogant, however, for responding to a personal query with a
clarification of *my opinion*.

> > What I do mind is threads that were not intended as golfing threads
> > being hijacked into a golf contest.
>
> I'm a wicked hijacker.  I know I am because Mr. Fugal told me so.

I never used the word wicked; please don't put words in my mouth.
Hijacking a newgroup thread is not evil, wicked or in any way morally
wrong.

> place on its receiver and, in this case, returns nil.'
Because I made a mistake. I'm glad that someone caught the mistake and
brought it to light. I have learned from it.

> puts chomper
>
> Even if there was a way for the loop to terminate, xx would not
> be returned.  It has to be moved outside of the loop.
> Extremely misleading.  Extremely confusing to a newbie.

Because I was focusing on the difference between chomp and chomp!,
about which I was mistake anyways. If you compare that code against
Johns original example you'll find one difference in one character:
the removal of the !. I made that one change because I believed,
mistakenly, that the difference between chomp and chomp! is what was
breaking my code. After jumping to that premature and mistaken
conclusion, I didn't take the time to proof the rest of his method. I
apologize for any confusion that may have caused.

> And it was extremely arrogant to post untested
> code.

No, it wasn't. It was lazy, yes. It was a mistake, yes. But not
arrogant.

> Furthermore, it was extremely rude as well as incredibly arrogant
> to assert falsely that my code wouldn't work correctly when
> you had not condescended to test it.

Again, that was based on my incorrect assumption about chomp! always
returning nil. I made a mistake. I apologize. I was not trying to be
rude, just helpful.

> 3. It is shorter.
I would argue point 2, but only due to personal taste. I concede points
1 and 3.

> Naturally, Mr. Fugal's arrogance compels him to dismiss
> my version by using the term "golf", hoping that you will
> assume that "golf" is a Bad Thing.

I did not dismiss your version because I thought it was golf. I
dismissed it because I thought, mistakenly, that is was incorrect. For
that I apologize.

Nor have I said golf is a Bad Thing; witness my clarification to which
you have responded.

> Newbies, don't be afraid of $_.  Matz didn't include it in Ruby
> in order to tempt the unwary into becoming "evil golfers".
> He included it because it is useful.  Of course, Mr. Fugal's
> arrogance leads him to believe that his opinion outweighs
> Matz's.

I never said golfing was evil. I never said or implied that Matz made
a mistake by including $_. I never said or implied that $_ is not
useful. And I definitely never said or implied that my opinion
outweighs that of Matz. Please do not attribute views to me that I do
not hold.

I discouraged the use of $_ because I believe it to be less readable
than using a named variable. Indeed, John's original post asked for a
way to incorporate a variable into his solution in place of the $_.

Jacob F.
Ezra Z. (Guest)
on 2006-02-03 19:46
(Received via mailing list)
>

William:  pot... kettle... black.

-Ezra
why the lucky stiff (Guest)
on 2006-02-03 20:01
(Received via mailing list)
Ezra Z. wrote:

> William:  pot... kettle... black.

Whoa, break out the racial slurs.  Someone is gonna find himself in some
pretty hot water!

Well, I guess certain dishes are just asking for it.

_why
Matthew M. (Guest)
on 2006-02-03 20:40
(Received via mailing list)
On 2/3/06, why the lucky stiff <removed_email_address@domain.invalid> wrote:
> Ezra Z. wrote:
>
> > William:  pot... kettle... black.
>
> Whoa, break out the racial slurs.  Someone is gonna find himself in some
> pretty hot water!

Pardon my breaking in here...  but how is that a racial slur?  Are you
not familiar with the expression "the pot calling the kettle black",
do you not know what pots and kettles are, or are you just trying to
be funny?
Jacob F. (Guest)
on 2006-02-03 20:46
(Received via mailing list)
On 2/3/06, Matthew M. <removed_email_address@domain.invalid> wrote:
> do you not know what pots and kettles are, or are you just trying to
> be funny?

You obviously have yet to know _why. :)

(Oh, and _why, nice pun there with the "hot water" comment, I didn't
get it until this second reading...)

Jacob F.
Matthew M. (Guest)
on 2006-02-03 22:06
(Received via mailing list)
> You obviously have yet to know _why. :)

Perhaps...  But it irks me to no end (to put it mildly) when someone
starts yelling racism where there is none.

However, if what you're saying is that it's a bad pun and I'm just to
dense to recognize it, fine. I'll go sit back in my corner.
Jacob F. (Guest)
on 2006-02-03 22:15
(Received via mailing list)
On 2/3/06, Matthew M. <removed_email_address@domain.invalid> wrote:
> > You obviously have yet to know _why. :)
>
> Perhaps...  But it irks me to no end (to put it mildly) when someone
> starts yelling racism where there is none.

No, _why wasn't actually claiming any real racism; as you theorize
below, it was just a pun.

> However, if what you're saying is that it's a bad pun and I'm just to
> dense to recognize it, fine. I'll go sit back in my corner.

As I said above, it's just that you have yet to be exposed to the full
force of that which we call _why. It can take a while -- I know it
took me some time -- to become accustomed to _why's brand of humor. If
you don't believe me, go hang out in #camping for a while. ;)

No offense intended... come back and play! :)

Jacob F.
This topic is locked and can not be replied to.