Why not Python? (No, no, I am not a spy)

Tolga [email protected] wrote:

One or two weeks ago, I tried Python and loved it. But I also hearing
ineteresting things about Ruby nowadays. Which language should I use?
Oh, yes, this question looks somewhat silly, this is a Ruby group and
people will tend to give an automatic “Ruby” reply. But as far as I
see, Ruby (and Python) has a intellectual community. So, I hope that I
will get logical explanations rather than “holigan” cries.

Whenever I’m asked for a one-word answer to why I prefer Ruby to Python,
that one word is ‘blocks’. If you’ve used lisp, you should appreciate
the power of full-fledged lexical closures, and ruby makes them
really convenient to use. Indeed, the standard library is built
to make heavy use of blocks, and the one free block per method
positively encourages their use. It’s really hard to describe how nice a
feature this is until you’ve used it for yourself, but a couple of weeks
investigating ruby should show you what I mean.

martin

Steve L. wrote:

Remember my thread on end matching, and how complex the answers
[email protected]

Sorry, but the indentation feature of Python (along with the mandatory
prefix self of every class method) is one of the worst design decisions
made by a language designer, and is what turned me away from Python to
Ruby.

That said, if there weren’t a Ruby, I would still be a Pythonista!

Baalbek

On Dec 22, 2005, at 9:07 PM, baalbek wrote:

job). That all becomes moot via subordination by indentation.
away from Python to Ruby.

That said, if there weren’t a Ruby, I would still be a Pythonista!

Baalbek

Excuse my newbi-ness, but isn’t that “self rule” for class methods
similar in Ruby? E.g.

class A
def self.a_class_method
puts “A class method”
end

OR

def A.another_class_method
	puts "Another class method"
end

end

~ ryan ~

On 12/22/05, J. Ryan S. [email protected] wrote:

    end

end

OR

class A
class << self
def foo; end
end
end

OR

class A
class << A
def foo; end
end
end

All equivalent in function definition (though surrounding scope can
differ inside class << declarations). It is similar but remember that
self is the class not an instance of the class.

Brian.

Actually, the one comparison that gets touched on a bit too lightly …
is
the community…

The python & ruby communities are VERY different. The above article
glasses
over it by saying:

“The Python is harder to get into because it’s larger than the ruby
community” …

Well, uh, no, that’s not true …

… I won’t go into details or start name-calling … but, go into a
chat
room for either, or post a simple message to either mailing list …

You’ll see the difference …

( Heh, and if you want an even stronger contrast, try asking simple
questions in a lisp irc channel … I’ve never had soo many people say
“We
aren’t going to help you with your homework” … ( I’m 30+ and have been
a
pro dev for about 10 of that … sorry, it’s NOT homework ). )

Anyways, really it all comes down to community, and I believe there is
NO
other programming language with a community that is so nice to people
and/or
easy to get along with ( even when there is strong disagreement ).

j.

On 12/22/05, Steve L. [email protected] wrote:

scoped, inconsistent API, writing C extensions sucks and it’s
seems so, well, so 1997. For me, life’s too short to use anything


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

Jeff W.

Hi –

On Fri, 23 Dec 2005, Brian M. wrote:

            puts "Another class method"

OR

class A
class << A
def foo; end
end
end

Also:

class A
end

and then:

class << A
def foo; end
end

or

def A.foo
end

David


David A. Black
[email protected]

“Ruby for Rails”, from Manning Publications, coming April 2006!

Hi –

On Fri, 23 Dec 2005, Gene T. wrote:

let’s not forget

def ClassName::clsmeth(params)
end

Oh, let’s :slight_smile: I really wish :: as a synonym for the dot would
disappear. I’ve never understood what purpose is served by it.

David


David A. Black
[email protected]

“Ruby for Rails”, from Manning Publications, coming April 2006!

[email protected] wrote:

            puts "A class method"

class << self
end
end

or

def A.foo
end

let’s not forget

def ClassName::clsmeth(params)
end

(either inside or outside class def, so that’s 5 ways to do it inside
class def, 3 outside for those keeping score at home, mostly python
hyperenthusiasts

Actually, no.

The ‘self’ in ruby is a keyword, hardcoded and built into the language.
(
Other languages use the same, java comes to mind ).

The ‘self’ in python is a self-inflicted community standard. They could
have
saved countless keystrokes around the world and just used ‘s’, ‘me’, or
‘my’
… but nope …

j.

On 12/22/05, J. Ryan S. [email protected] wrote:

What exactly did make you feel happy?

Excuse my newbi-ness, but isn’t that “self rule” for class methods
end

~ ryan ~


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

Jeff W.

Jeff W. [email protected] writes:

Actually, the one comparison that gets touched on a bit too lightly … is
the community…

( Heh, and if you want an even stronger contrast, try asking simple
questions in a lisp irc channel … I’ve never had soo many people say “We
aren’t going to help you with your homework” … ( I’m 30+ and have been a
pro dev for about 10 of that … sorry, it’s NOT homework ). )

I’d be really curious about what you asked there. :slight_smile:

Anyways, really it all comes down to community, and I believe there is NO
other programming language with a community that is so nice to people and/or
easy to get along with ( even when there is strong disagreement ).

[email protected] wrote:

Oh, let’s :slight_smile: I really wish :: as a synonym for the dot would
disappear. I’ve never understood what purpose is served by it.

if “::” is used exclusively for class constants, i guess it’s slightly
useful, otherwise i tend to agree

Jeff W. wrote:

Anyways, really it all comes down to community, and I believe there is NO
other programming language with a community that is so nice to people and/or
easy to get along with ( even when there is strong disagreement ).

I agree. After communicating in various communities I have found Ruby
by far to be the most receptive, patient, friendly, etc. This is after
communicating with Perl, C++, Java, VB, and other folks. From newbies
to experienced gurus, everyone for the most part is welcomed in the
world of Ruby. Let’s hope as the language continues to gain exposure
and adoption this trend continues. It’s difficult to imagine as the
community expands, but let’s hope!

As long as we haven’t already gathered up all of the nice people, I
don’t
see us having any problems … :wink:

j.

On 12/23/05, gregarican [email protected] wrote:

by far to be the most receptive, patient, friendly, etc. This is after
communicating with Perl, C++, Java, VB, and other folks. From newbies
to experienced gurus, everyone for the most part is welcomed in the
world of Ruby. Let’s hope as the language continues to gain exposure
and adoption this trend continues. It’s difficult to imagine as the
community expands, but let’s hope!


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

Jeff W.

… I believe the question was in regards to implementing factorial in a
tail-recursive manner.

I believe the statement was:

“I’m a complete newb to lisp, I’ve been reading Practical Common Lisp &
On
Lisp. I’ve also been working through “The little schemer” and SICP…
I’m
running CMUCL under SLIME & Emacs (v21.4). ( phew ) … I’ve written an
iterative & a normally recursive version of factorial … Now I’m trying
to
figure out how to implement it in a tail-recursive fashion … can
anybody
help me write a tail-recursive version ?? I’m not familiar with the call
pattern yet.” …

or something like that …

j.

On 12/23/05, Christian N. [email protected] wrote:

aren’t going to help you with your homework" … ( I’m 30+ and have been

Jeff W.

Christian N. [email protected] http://chneukirchen.org


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

Jeff W.

Three years ago I wanted to put all of the medical records of my office
into a Zaurus pda. However, the Zaurus
used python with QT as a GUI. The office system is on Windows 2000.
So, I had to learn python to program the
Zaurus but I could use Ruby on the office computers because those
programs were command line and did not depend
on a GUI. It took me half the time for the Ruby programs compared to
programming the python component. So I much
prefer ruby.

On another note, having used Fox, QT, and Tk as GUI’s I found that QT is
by far the best documented and flexible GUI.

T. A. Reilly M.D.

ah, but to me that isn’t completely iterative… iterative is using a
loop
within a function to make sure it and all functions it calls do not call
back up the tree…

hence:

yes assumptions about positive integer numbers…

complete recursive:

def factorial( x )
return 0 if x < 1
x * factorial( x - 1 )
end

tail-recursive:

def factorial( x, sum = 1 )
return 0 if x < 1
factorial( ( x - 1 ), ( sum * x ) )
end

iterative:

def factorial( x )
sum = 1
for i in (1…x).to_a
sum *= i
end
end

… anyways.

j.

On 12/23/05, Christian N. [email protected] wrote:

Lisp. I’ve also been working through “The little schemer” and SICP…
http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-21.html#%_thm_3.9


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

Jeff W.

heh, darn, bug there …

yes assumptions about positive integer numbers…

factorial of 0 is undefined …

complete recursive:

def factorial( x )
return 1 if x < 1
x * factorial( x - 1 )
end

tail-recursive:

def factorial( x, sum = 1 )
return 1 if x < 1
factorial( ( x - 1 ), ( sum * x ) )
end

iterative:

def factorial( x )
sum = 1
for i in (1…x).to_a
sum *= i
end
end

On 12/23/05, Jeff W. [email protected] wrote:

def factorial( x )

tail-recursive manner.
trying to
They could have told you that, of course.

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

Jeff W.


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

Jeff W.

Jeff W. [email protected] writes:

help me write a tail-recursive version ?? I’m not familiar with the call
pattern yet." …

I see, the iterative version at
http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-21.html#%_thm_3.9
actually is the tail-recursive version. :slight_smile:

They could have told you that, of course.

On 12/23/05, Jeff W. [email protected] wrote:

return 0 if x < 1
end
With bugfixes:

complete recursive:

def factorial( x )
return 1 if x < 1
x * factorial( x - 1 )
end

tail-recursive:

def factorial( x, sum = 1 )
return sum if x < 1
factorial( ( x - 1 ), ( sum * x ) )
end

iterative:

def factorial( x )
sum = 1
for i in (1…x).to_a
sum *= i
end
sum
end

:slight_smile:

Jacob F.

uh, yeah, that’s what I meant … darn’d quickie code always bites me in
the
butt …

j.

On 12/23/05, Jacob F. [email protected] wrote:

sum *= i
  sum *= i
end
sum

end

:slight_smile:

Jacob F.


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

Jeff W.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs