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.
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!
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.
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 ).
(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
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 …
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.
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 ).
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!
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!
… 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.” …
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.
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