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

J

Jeff Wood

------=_Part_1478_14167796.1135276764624
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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 glasse=
s
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/o=
r
easy to get along with ( even when there is strong disagreement ).


j.


If you read between the lines in this thread, you notice that only
Python and Ruby are mentioned in positive light. Nobody stood up
for Perl, or VB, or Pascal, or C++, or Java. Ruby and Python have
obviously done something right, well beyond the convenience and
capabilities of other languages of our time.

I've used Perl since 1997, and fell so in love with Perl that my
wife hired a private investigator, but since I've found Ruby, Perl
seems so, well, so 1997. For me, life's too short to use anything
but Ruby or Python in typical small to moderately sized programs
that aren't extremely computation heavy (simulation and the like).

SteveT


Steve Litt
http://www.troubleshooters.com
(e-mail address removed)


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

Jeff Wood

------=_Part_1478_14167796.1135276764624--
 
M

Martin DeMello

Tolga said:
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
 
B

baalbek

Steve said:
What makes me happy about Python is subordination by indentation.
Remember my thread on end matching, and how complex the answers
became (one responder suggested getting a Ruby parser to do the
job). That all becomes moot via subordination by indentation.

If I screw up the indentation, I get either a syntax error or *very
obvious* runtime error.

SteveT

Steve Litt
http://www.troubleshooters.com
(e-mail address removed)

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
 
J

J. Ryan Sobol

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

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 ~
 
B

Brian Mitchell

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

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.
 
G

Gene Tani

Hi --



Also:

class A
end

and then:

class << A
def foo; 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
 
G

Gene Tani

Oh, let's :) 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
 
J

Jeff Wood

------=_Part_8044_28721715.1135339066415
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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 hav=
e
saved countless keystrokes around the world and just used 's', 'me', or 'my=
'
... but nope ...

j.

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 ~


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

Jeff Wood

------=_Part_8044_28721715.1135339066415--
 
G

gregarican

Jeff said:
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!
 
J

Jeff Wood

------=_Part_10357_29263074.1135353154886
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

... 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.

n

I'd be really curious about what you asked there. :)


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

Jeff Wood

------=_Part_10357_29263074.1135353154886--
 
J

Jeff Wood

------=_Part_10365_28689130.1135353215211
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

As long as we haven't already gathered up all of the nice people, I don't
see us having any problems ... ;)

j.

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!


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

Jeff Wood

------=_Part_10365_28689130.1135353215211--
 
T

Tom Reilly

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.
 
J

Jeff Wood

------=_Part_12914_23737615.1135366588960
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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 =3D 1 )
return 0 if x < 1
factorial( ( x - 1 ), ( sum * x ) )
end

# iterative:

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

... anyways.

j.



g

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. :)

They could have told you that, of course.


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

Jeff Wood

------=_Part_12914_23737615.1135366588960--
 
J

Jeff Wood

------=_Part_12930_27437977.1135366703656
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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 =3D 1 )
return 1 if x < 1
factorial( ( x - 1 ), ( sum * x ) )
end

# iterative:

def factorial( x )
sum =3D 1
for i in (1..x).to_a
sum *=3D i
end
end
 
J

Jacob Fugal

# complete recursive:

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

# tail-recursive:

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

# iterative:

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

With bugfixes:

# complete recursive:
def factorial( x )
return 1 if x < 1
x * factorial( x - 1 )
end

# tail-recursive:
def factorial( x, sum =3D 1 )
return sum if x < 1
factorial( ( x - 1 ), ( sum * x ) )
end

# iterative:
def factorial( x )
sum =3D 1
for i in (1..x).to_a
sum *=3D i
end
sum
end

:)

Jacob Fugal
 
F

Florian Frank

Jeff said:
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
return 1 if x <= 1
x * factorial( x - 1 )
end

# tail-recursive:

def factorial( x, sum = 1 )
return 1 if x < 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
for i in 1..x
sum *= i
end
end
And why do you call your products "sum"?
 
J

Jeff Wood

------=_Part_13058_6536305.1135367845542
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

uh, yeah, that's what I meant ... darn'd quickie code always bites me in th=
e
butt ...

j.


With bugfixes:

# complete recursive:
def factorial( x )
return 1 if x < 1
x * factorial( x - 1 )
end

# tail-recursive:
def factorial( x, sum =3D 1 )
return sum if x < 1
factorial( ( x - 1 ), ( sum * x ) )
end

# iterative:
def factorial( x )
sum =3D 1
for i in (1..x).to_a
sum *=3D i
end
sum
end

:)

Jacob Fugal


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

Jeff Wood

------=_Part_13058_6536305.1135367845542--
 
S

Stephen Kellett

Steve Litt said:
If you read between the lines in this thread, you notice that only
Python and Ruby are mentioned in positive light. Nobody stood up
for Perl, or VB, or Pascal, or C++, or Java.

OK then. I will. C++ is fantastic. Most likely for jobs you would not or
could not use Ruby for. The products I work on require C++/C and
assembler. You couldn't possibly write them in Ruby. Even if you could
they would be too slow.

When I'm not using C++, Ruby is what I am using, or intending to use.

Java - I always felt like I was writing code whilst wearing a straight
jacket. In 9 years of using Java (I started in May 1996) I didn't like
it - but you use what you are asked to use by the customer.

Merry Christmas

Stephen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top