[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Re: Bruce Eckel wouldn't know why to switch from Python to Ruby

tony summerfelt

12/22/2005 1:31:00 PM

Doug H wrote on 12/20/2005 6:42 PM:
> #python:

> #ruby:

is it just me or did that ruby code look a lot cleaner?
--
http://home.cogeco.ca/~ts...
telnet://ventedspleen.dyndns.org



15 Answers

gabriele renzi

12/22/2005 6:43:00 PM

0

tony summerfelt ha scritto:
> Doug H wrote on 12/20/2005 6:42 PM:
>
>>#python:
>
>
>>#ruby:
>
>
> is it just me or did that ruby code look a lot cleaner?

I think everyone can agree :)

But the python approach is maybe a little more pragmatic, in most use
cases you'd write this in ruby:
class Foo
attr_accessor :foo
def initialize foo
@foo = foo
end
end
end
while in python it would be:
class Foo:
def __init__(slf,foo):
slf.foo=foo

relying on the fact that you could translate variable access into an
accessor method when needed withouth breaking the interface.
OTOH some hardcore-OO people could object that allowing access to
instance variables by default may be a bad habit.
tomayto tomahto, I'd say.

Jeff Wood

12/22/2005 6:50:00 PM

0

... be careful, you're gonna bring down the python coding police ...

Although not a physical requirement of the runtime, you named your first
variable in the class method slf ... the python community would eat you
alive for that ...

They prefer ( and *ALL* their docs make sure to tell you over and over )
that the first parameter of the class method be named self.

... Dive into python and every other tutorial on the topic actually stops to
make sure you understand this ...

I find it humorous ... and a bit retentive ... but, to each their own.

j.

On 12/22/05, gabriele renzi <surrender_it@-remove-yahoo.it> wrote:
>
> tony summerfelt ha scritto:
> > Doug H wrote on 12/20/2005 6:42 PM:
> >
> >>#python:
> >
> >
> >>#ruby:
> >
> >
> > is it just me or did that ruby code look a lot cleaner?
>
> I think everyone can agree :)
>
> But the python approach is maybe a little more pragmatic, in most use
> cases you'd write this in ruby:
> class Foo
> attr_accessor :foo
> def initialize foo
> @foo = foo
> end
> end
> end
> while in python it would be:
> class Foo:
> def __init__(slf,foo):
> slf.foo=foo
>
> relying on the fact that you could translate variable access into an
> accessor method when needed withouth breaking the interface.
> OTOH some hardcore-OO people could object that allowing access to
> instance variables by default may be a bad habit.
> tomayto tomahto, I'd say.
>
>


--
"Remember. Understand. Believe. Yield! -> http://ruby-lang...

Jeff Wood

Chad Perrin

12/22/2005 7:16:00 PM

0

On Fri, Dec 23, 2005 at 03:42:50AM +0900, gabriele renzi wrote:
> while in python it would be:
> class Foo:
> def __init__(slf,foo):
> slf.foo=foo

Argh. It looks unfinished. It's asymmetrical, and not in a beautiful
way.

It's shorter than the Ruby example, but it makes my eyes bleed. An
episode of The Apprentice is shorter than The Maltese Falcon, too, but
it's a hell of a lot uglier.

. . at least, for my taste.

When I want short code, I write it in Perl.

--
Chad Perrin [ CCD CopyWrite | http://ccd.ap... ]

unix virus: If you're using a unixlike OS, please forward
this to 20 others and erase your system partition.


gabriele renzi

12/23/2005 3:14:00 AM

0

Jeff Wood ha scritto:
> .. be careful, you're gonna bring down the python coding police ...
>
> Although not a physical requirement of the runtime, you named your first
> variable in the class method slf ... the python community would eat you
> alive for that ...
>
> They prefer ( and *ALL* their docs make sure to tell you over and over )
> that the first parameter of the class method be named self.
>
> .. Dive into python and every other tutorial on the topic actually stops to
> make sure you understand this ...
>
> I find it humorous ... and a bit retentive ... but, to each their own.
>
> j.

you're absolutely right, but in my defense I can say that I did write
that becuase I feel the need to explicitly name self dumb. I find it ok
to write self.foo but naming the argument is just useless imho.

gabriele renzi

12/23/2005 3:15:00 AM

0

Chad Perrin ha scritto:
> On Fri, Dec 23, 2005 at 03:42:50AM +0900, gabriele renzi wrote:
>
>>while in python it would be:
>> class Foo:
>> def __init__(slf,foo):
>> slf.foo=foo
>
>
> Argh. It looks unfinished. It's asymmetrical, and not in a beautiful
> way.
>
> It's shorter than the Ruby example, but it makes my eyes bleed. An
> episode of The Apprentice is shorter than The Maltese Falcon, too, but
> it's a hell of a lot uglier.
>
> . . at least, for my taste.
>
> When I want short code, I write it in Perl.

de gustibus non est disputandum

Chad Perrin

12/23/2005 3:22:00 AM

0

On Fri, Dec 23, 2005 at 12:17:50PM +0900, gabriele renzi wrote:
> Chad Perrin ha scritto:
> >On Fri, Dec 23, 2005 at 03:42:50AM +0900, gabriele renzi wrote:
> >
> >>while in python it would be:
> >>class Foo:
> >> def __init__(slf,foo):
> >> slf.foo=foo
> >
> >
> >Argh. It looks unfinished. It's asymmetrical, and not in a beautiful
> >way.
> >
> >It's shorter than the Ruby example, but it makes my eyes bleed. An
> >episode of The Apprentice is shorter than The Maltese Falcon, too, but
> >it's a hell of a lot uglier.
> >
> > . . at least, for my taste.
> >
> >When I want short code, I write it in Perl.
>
> de gustibus non est disputandum

Um. Okay?

--
Chad Perrin [ CCD CopyWrite | http://ccd.ap... ]

unix virus: If you're using a unixlike OS, please forward
this to 20 others and erase your system partition.


Robert Klemme

12/23/2005 8:31:00 AM

0

Chad Perrin wrote:
> On Fri, Dec 23, 2005 at 12:17:50PM +0900, gabriele renzi wrote:
>> Chad Perrin ha scritto:
>>> On Fri, Dec 23, 2005 at 03:42:50AM +0900, gabriele renzi wrote:
>>>
>>>> while in python it would be:
>>>> class Foo:
>>>> def __init__(slf,foo):
>>>> slf.foo=foo
>>>
>>>
>>> Argh. It looks unfinished. It's asymmetrical, and not in a
>>> beautiful way.
>>>
>>> It's shorter than the Ruby example, but it makes my eyes bleed. An
>>> episode of The Apprentice is shorter than The Maltese Falcon, too,
>>> but it's a hell of a lot uglier.
>>>
>>> . . at least, for my taste.
>>>
>>> When I want short code, I write it in Perl.
>>
>> de gustibus non est disputandum
>
> Um. Okay?

We Germans say "Über Geschmäcker kann man streiten" - interestingly enough
it's the negated translation of the Latin "You cannot argue about
likings"... :-)

robert

Patrick Hurley

12/23/2005 2:41:00 PM

0

On 12/22/05, Chad Perrin <perrin@apotheon.com> wrote:
> On Fri, Dec 23, 2005 at 12:17:50PM +0900, gabriele renzi wrote:
> > Chad Perrin ha scritto:
> > de gustibus non est disputandum
>
> Um. Okay?

Four years of high school (although that was sometime ago now) to the rescue:

In matters of taste there can be no dispute.

Colloquially in English: you say potato, I say potato :-)


Steve Litt

12/23/2005 3:47:00 PM

0

On Friday 23 December 2005 09:40 am, Patrick Hurley wrote:
> On 12/22/05, Chad Perrin <perrin@apotheon.com> wrote:
> > On Fri, Dec 23, 2005 at 12:17:50PM +0900, gabriele renzi wrote:
> > > Chad Perrin ha scritto:
> > > de gustibus non est disputandum
> >
> > Um. Okay?
>
> Four years of high school (although that was sometime ago now) to
> the rescue:
>
> In matters of taste there can be no dispute.
>
> Colloquially in English: you say potato, I say potato :-)

Is de gustibus non est disputandum Italian, Latin or something else?
I can think of many threads I'd like to use that phrase in.

SteveT

Steve Litt
http://www.troublesh...
slitt@troubleshooters.com


Jeff Wood

12/23/2005 3:54:00 PM

0

latin.

On 12/23/05, Steve Litt <slitt@earthlink.net> wrote:
>
> On Friday 23 December 2005 09:40 am, Patrick Hurley wrote:
> > On 12/22/05, Chad Perrin <perrin@apotheon.com> wrote:
> > > On Fri, Dec 23, 2005 at 12:17:50PM +0900, gabriele renzi wrote:
> > > > Chad Perrin ha scritto:
> > > > de gustibus non est disputandum
> > >
> > > Um. Okay?
> >
> > Four years of high school (although that was sometime ago now) to
> > the rescue:
> >
> > In matters of taste there can be no dispute.
> >
> > Colloquially in English: you say potato, I say potato :-)
>
> Is de gustibus non est disputandum Italian, Latin or something else?
> I can think of many threads I'd like to use that phrase in.
>
> SteveT
>
> Steve Litt
> http://www.troublesh...
> slitt@troubleshooters.com
>
>


--
"Remember. Understand. Believe. Yield! -> http://ruby-lang...

Jeff Wood