What we need is a code snippet that is excessively long and obfuscate in
Perl, such as a single line of code which has to wrap around the t-shirt to
be completed (with all the @ and $ symbols, etc.), and then do the same in
Ruby underneath… which only takes a fraction of the width of the front
side of the shirt.
IMHO it will be almost impossible to do that, being fair and idiomatic
with the Perl version, writing readable Perl, and getting that ratio at
the same time.
Though I would be glad if I was proved wrong :-).
– fxn
···
On Thursday 10 July 2003 22:32, Orion Hunter wrote:
What we need is a code snippet that is excessively long and obfuscate
in Perl, such as a single line of code which has to wrap around the
t-shirt to be completed (with all the @ and $ symbols, etc.), and
then do the same in Ruby underneath… which only takes a fraction of
the width of the front side of the shirt.
Suppose you wanted to iterate through an array and
print out the odd-numbered elements:
array.each_with_index {|x,i| puts x if i % 2 == 1 }
How would that look in Perl?
Hal
···
----- Original Message -----
From: “Xavier Noria” fxn@hashref.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Thursday, July 10, 2003 4:35 PM
Subject: Re: Ruby T-Shirt Idea
On Thursday 10 July 2003 22:32, Orion Hunter wrote:
What we need is a code snippet that is excessively long and obfuscate
in Perl, such as a single line of code which has to wrap around the
t-shirt to be completed (with all the @ and $ symbols, etc.), and
then do the same in Ruby underneath… which only takes a fraction of
the width of the front side of the shirt.
IMHO it will be almost impossible to do that, being fair and idiomatic
with the Perl version, writing readable Perl, and getting that ratio at
the same time.
Something OO? With all the blessing and stuff, Perl is quite ugly, esp.
when compared to the neatness of Ruby…
···
On Fri, Jul 11, 2003 at 06:35:27AM +0900, Xavier Noria wrote:
On Thursday 10 July 2003 22:32, Orion Hunter wrote:
What we need is a code snippet that is excessively long and obfuscate
in Perl, such as a single line of code which has to wrap around the
t-shirt to be completed (with all the @ and $ symbols, etc.), and
then do the same in Ruby underneath… which only takes a fraction of
the width of the front side of the shirt.
IMHO it will be almost impossible to do that, being fair and idiomatic
with the Perl version, writing readable Perl, and getting that ratio at
the same time.
That’s a good intent because Perl lacks an explicit construct to iterate
with both the index and the element, and does not come with a puts()
in addition.
For instance we could write
$_ % 2 and print "$array[$_]\n" foreach 0..$#array;
If one considers it’s bad style to use boolean operators to control flow
that way, we could write instead
foreach (0..$#array) {
print "$array[$_]\n" if $_ % 2;
}
Note that I have not used “for”, which is wholly interchangeable with
“foreach”, to shorten the snippets. I prefer to write foreach when I
mean foreach.
I woldn’t be proud wearing a T-shirt that compared Ruby to any other
language that way. Both Ruby and Perl have their place, I love both.
– fxn
···
On Thursday 10 July 2003 23:42, Hal E. Fulton wrote:
Suppose you wanted to iterate through an array and
print out the odd-numbered elements:
array.each_with_index {|x,i| puts x if i % 2 == 1 }
What we need is a code snippet that is excessively long and
obfuscate in Perl, such as a single line of code which has
to wrap around the t-shirt to be completed (with all the @
and $ symbols, etc.), and then do the same in Ruby
underneath… which only takes a fraction of the width of
the front side of the shirt.
IMHO it will be almost impossible to do that, being fair and
idiomatic with the Perl version, writing readable Perl, and
getting that ratio at the same time.
Though I would be glad if I was proved wrong :-).
Something OO? With all the blessing and stuff, Perl is quite
ugly, esp. when compared to the neatness of Ruby…
Non-OO, idiomatic Perl can almost always beat ruby by at least a
few characters. OO Perl automatically doubles the length (and
execution time) of a program.
IMHO, whatever snippet chosen should make effective use of
iterators, as this is probably the feature that makes Ruby the
most unique among its contemporary counterparts.
Cheers,
Tim Hammerquist
···
–
Ford, you’re turning into a penguin. Stop it.
– Arthur Dent, “The Hitchhiker’s Guide to the Galaxy”
If you want to print out the odd-numbered elements themselves:
foreach (@array) { print "$\n" if $ %2; }
When I said the odd-NUMBERED elements, I meant the elements which
are NUMBERED (indexed) by odd numbers – not that the elements
themselves should be odd. In fact, I was thinking that the
elements were strings, though I didn’t say that. Ahh, dynamic typing…
Thanks for the Perl lesson… I can always use one.
Though I’m really thinking of looking at Python instead…
Cheers,
Hal
···
----- Original Message -----
From: “Eric Schwartz” emschwar@pobox.com
Newsgroups: comp.lang.ruby
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Thursday, July 10, 2003 5:22 PM
Subject: Re: Ruby T-Shirt Idea
lrwxr-xr-x 1 root 1 Jan 2003 java →
/usr/bin/ruby
lrwxr-xr-x 1 root 1 Jan 2003 perl → /usr/bin/ruby
lwxr-xr-x 1 root 1 Jan 2003 php → /usr/bin/ruby
lrwxr-xr-x 1 root 1 Jan 2003 python → /usr/bin/ruby
lrwxr-xr-x 1 root 1 Jan 2003 sh → /usr/bin/irb
lrwxr-xr-x 1 root 1 Jan 2003 tcl → /usr/bin/ruby
-ronnie
Tim Hammerquist wrote:
Mauricio Fernández graced us by uttering:
Xavier Noria wrote:
Orion Hunter wrote:
What we need is a code snippet that is excessively long and
obfuscate in Perl, such as a single line of code which has
to wrap around the t-shirt to be completed (with all the @
and $ symbols, etc.), and then do the same in Ruby
underneath… which only takes a fraction of the width of
the front side of the shirt.
IMHO it will be almost impossible to do that, being fair and
idiomatic with the Perl version, writing readable Perl, and
getting that ratio at the same time.
Though I would be glad if I was proved wrong :-).
Something OO? With all the blessing and stuff, Perl is quite
ugly, esp. when compared to the neatness of Ruby…
Non-OO, idiomatic Perl can almost always beat ruby by at least a
few characters. OO Perl automatically doubles the length (and
execution time) of a program.
IMHO, whatever snippet chosen should make effective use of
iterators, as this is probably the feature that makes Ruby the
most unique among its contemporary counterparts.
lrwxr-xr-x 1 root 1 Jan 2003 java → /usr/bin/ruby
lrwxr-xr-x 1 root 1 Jan 2003 perl → /usr/bin/ruby
lrwxr-xr-x 1 root 1 Jan 2003 php → /usr/bin/ruby
lrwxr-xr-x 1 root 1 Jan 2003 python → /usr/bin/ruby
lrwxr-xr-x 1 root 1 Jan 2003 sh → /usr/bin/irb
lrwxr-xr-x 1 root 1 Jan 2003 tcl → /usr/bin/ruby
Reminds me of an answer posted on the vim mailing list:
: > …any ideas on how to make vim behave like the ‘tail’ command in unix?
: >
:
: On my system “cp /usr/bin/tail /usr/local/bin/vim” does the trick,
: though Vi compatibility is subsequently somewhat impaired.