[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Beautiful Code : Pity he didn't ask here...

John Carter

7/11/2007 11:11:00 PM

14 Answers

Tom Copeland

7/12/2007 1:18:00 AM

0

On Thu, 2007-07-12 at 08:11 +0900, John Carter wrote:
> I try to write the most readable code that is most readable by someone
> who knows Ruby perfectly well.

Right on. Today Rich Kilmer showed me some Rails code that Chad Fowler
had written. It was something like:

some_array.map(&:name)

where some_array was filled with objects that had a name attribute, and
Rails reopened Symbol and added to_proc.

At first I thought "oh, that's ridiculous". Five minutes later I
thought "hm, that's rather nice". Five minutes later I agreed with Rich
that it was very clever and we would start using it everywhere :-)

> Personally I would speak up to them. Scan the libraries for the best
> code Rubiest have to offer in the Ruby idiom.... and spend my time
> explaining the elegance, power and succinctness of it.

Well said!

Yours,

Tom



Ezra Zygmuntowicz

7/12/2007 1:25:00 AM

0


On Jul 11, 2007, at 6:18 PM, Tom Copeland wrote:

> Right on. Today Rich Kilmer showed me some Rails code that Chad
> Fowler
> had written. It was something like:
>
> some_array.map(&:name)

Careful with that one Tom. It's *a lot* slower then writing out the
block since creating a Proc object has some overhead. Syntactically
it's very nice but performance wise it stinks.


Cheers-
-- Ezra Zygmuntowicz
-- Lead Rails Evangelist
-- ez@engineyard.com
-- Engine Yard, Serious Rails Hosting
-- (866) 518-YARD (9273)



Tom Copeland

7/12/2007 1:30:00 AM

0

On Thu, 2007-07-12 at 10:25 +0900, Ezra Zygmuntowicz wrote:
> On Jul 11, 2007, at 6:18 PM, Tom Copeland wrote:
>
> > Right on. Today Rich Kilmer showed me some Rails code that Chad
> > Fowler
> > had written. It was something like:
> >
> > some_array.map(&:name)
>
> Careful with that one Tom. It's *a lot* slower then writing out the
> block since creating a Proc object has some overhead. Syntactically
> it's very nice but performance wise it stinks.

Ah, cool, OK, thanks for the heads up!

Yours,

Tom



ara.t.howard

7/12/2007 2:38:00 AM

0


On Jul 11, 2007, at 7:30 PM, Tom Copeland wrote:

> Ah, cool, OK, thanks for the heads up!


yeah! i'm always on the lookout for code that runs slow but reads
great - just my style ;-)

-a
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama




Jeremy Hinegardner

7/12/2007 2:46:00 AM

0

On Thu, Jul 12, 2007 at 11:38:00AM +0900, ara.t.howard wrote:
>
> On Jul 11, 2007, at 7:30 PM, Tom Copeland wrote:
>
> >Ah, cool, OK, thanks for the heads up!
>
>
> yeah! i'm always on the lookout for code that runs slow but reads
> great - just my style ;-)

I predict the following code will appear in a codeforpeople example
soon.

some_ara.map(&:fortytwo)

enjoy,

-jeremy>

--
========================================================================
Jeremy Hinegardner jeremy@hinegardner.org


Martin DeMello

7/12/2007 8:04:00 AM

0

On 7/12/07, Jeremy Hinegardner <jeremy@hinegardner.org> wrote:
> I predict the following code will appear in a codeforpeople example
> soon.
>
> some_ara.map(&:fortytwo)

That's definitely one route towards intestinal fortytwod :)

martin

Robert Dober

7/12/2007 8:31:00 AM

0

On 7/12/07, Jeremy Hinegardner <jeremy@hinegardner.org> wrote:
> On Thu, Jul 12, 2007 at 11:38:00AM +0900, ara.t.howard wrote:
> >
> > On Jul 11, 2007, at 7:30 PM, Tom Copeland wrote:
> >
> > >Ah, cool, OK, thanks for the heads up!
> >
> >
> > yeah! i'm always on the lookout for code that runs slow but reads
> > great - just my style ;-)
>
> I predict the following code will appear in a codeforpeople example
> soon.
>
> some_ara.map(&:fortytwo)
Got you finally!!!,
It as all your fault, 42 (or :fourtytwo ) is a mystery constant.
That has to change

ANSWER_TO_THE_QUESTION_ABOUT_THE_MEANING_OF_LIFE_THE_UNIVERSE_AND_EVERYTHING
= 42

It might be a good idea to include the ISBN of the "Hitchhikers Guide
through the Galaxy" into the constant too.

Robert
--
I always knew that one day Smalltalk would replace Java.
I just didn't know it would be called Ruby
-- Kent Beck

Hal E. Fulton

7/12/2007 10:18:00 PM

0

Martin DeMello wrote:
> On 7/12/07, Jeremy Hinegardner <jeremy@hinegardner.org> wrote:
>> I predict the following code will appear in a codeforpeople example
>> soon.
>>
>> some_ara.map(&:fortytwo)
>
> That's definitely one route towards intestinal fortytwod :)

That pun was despicable and pernicious, and I am disappointed in you...
for having thought of it before I did.


Hal

big john whine

12/8/2010 7:13:00 AM

0

On Dec 7, 12:48 pm, rfisc...@sonic.net (Ray Fischer) wrote:
> Ernst Blofeld  <blofel...@hotmail.com> wrote:
>
> >On Dec 6, 9:23 pm, Yoorg...@Jurgis.net wrote:
>
> >> >Did the heroin addict seek heroin from me?
>
> >> Niger has no Yellow cake to sell
>
> >Does that change whether the addict SOUGHT, not bought but SOUGHT,
>
> Bush lied to the world in order to justify killing hundreds of
> thousands of people, and this cult asshole will do nothing but resort
> to lie after lie after lie in order to justify the killing.
>
> He'd have made a great nazi.
>
> --
> Ray Fischer         |  Mendacracy (n.) government by lying
> rfisc...@sonic.net  |  The new GOP ideal

you have to come to the conclusion sooner or later that there is no
point in talking to ppl who think that out and out lying is alright
under the guise of lawyer-style debate strategy.
lawyers are liars and their techniques are subjects of study and
discourse in universities.
of course, some ppl are just 'naturals'.

Rick Saunders

12/8/2010 1:14:00 PM

0

On Dec 8, 12:39 am, rfisc...@sonic.net (Ray Fischer) wrote:
> Rick Saunders  <retro_...@yahoo.com> wrote:
>
>
>
>
>
> >On Dec 7, 1:48 pm, rfisc...@sonic.net (Ray Fischer) wrote:
> >> Ernst Blofeld <blofel...@hotmail.com> wrote:
>
> >> >On Dec 6, 9:23 pm, Yoorg...@Jurgis.net wrote:
>
> >> >> >Did the heroin addict seek heroin from me?
>
> >> >> Niger has no Yellow cake to sell
>
> >> >Does that change whether the addict SOUGHT, not bought but SOUGHT,
>
> >> Bush lied to the world in order to justify killing hundreds of
> >> thousands of people, and this cult asshole will do nothing but resort
> >> to lie after lie after lie in order to justify the killing.
>
> >Still waiting for Raytard to prove any "lies."
>
> No you're not, rightard.  You cling to the same old discredited
> propaganda like a crazy cultist.  You're impervious to any and all
> facts.

Um, hello? I'm the only one presenting facts. You haven't come
back with a fucking thing except bitter denial. Where are your cites,
Ray? Where are YOUR facts?