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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Tolga (Guest)
on 2005-12-21 18:59
(Received via mailing list)
First of all and very first of all, I must state that I am not an enemy
or a spy :-D

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.

By the way, I am not a computer scientist and these are the reasons why
I want to learn Python or Ruby. Please consider them when replying:
1. I am not a computer scientist.
2. I AM interested in artificial intelligence and this is the major
reason for me to learn a programming language.
3. I am familiar, but not experienced, in BASIC, C/C++, Java, Prolog
and Lisp.
4. I am *NOT* interested in web programming at all
5. Nice GUIs always attract me. It is not mandatory but if Ruby can
provide me this (better than Python) I may immediately run to Ruby.
6. And finally, what is "Rails"? Do I have to learn it if I dive into
Ruby? Does it necessary for only web?

Waiting your replies.
Thank you very much in advance.
pat eyler (Guest)
on 2005-12-21 19:11
(Received via mailing list)
On 12/21/05, Tolga <removed_email_address@domain.invalid> wrote:
> First of all and very first of all, I must state that I am not an enemy
> or a spy :-D
>
> 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.

Well, there has already been a lot of discussion around this.  To me it
comes down to some unscientific bits.  Everytime I've picked up python,
it's made my head hurt.  It doesn't seem to match the way I think.

I'm not a super hacker, with experience in a whole bunch of languages,
but Ruby has made me a better programmer.  Even as a lightweight, I've
been able to put together some cool tools, pick up some good habits,
and even teach other people a bit.  The way that Ruby fits my thinking
and hacking patterns has a lot to do with my success.
>
> By the way, I am not a computer scientist and these are the reasons why
> I want to learn Python or Ruby. Please consider them when replying:
> 1. I am not a computer scientist.

Not really a problem, but I think you'll find that with Ruby you start
doing
things that make you look like a computer scientist ... it just comes
naturally.

> 2. I AM interested in artificial intelligence and this is the major
> reason for me to learn a programming language.
> 3. I am familiar, but not experienced, in BASIC, C/C++, Java, Prolog
> and Lisp.
> 4. I am *NOT* interested in web programming at all

Not even a requirement.

> 5. Nice GUIs always attract me. It is not mandatory but if Ruby can
> provide me this (better than Python) I may immediately run to Ruby.
> 6. And finally, what is "Rails"? Do I have to learn it if I dive into
> Ruby? Does it necessary for only web?

Rails is a web programming framework. A lot of people like it, some
people
(even Ruby folk) don't.  You don't need to go anywhere near it if you
don't
want to.
Jeff W. (Guest)
on 2005-12-21 19:14
(Received via mailing list)
On 12/21/05, Tolga <removed_email_address@domain.invalid> wrote:
>
> 6. And finally, what is "Rails"? Do I have to learn it if I dive into
> Ruby? Does it necessary for only web?
>
> Waiting your replies.
> Thank you very much in advance.



#2

Visit http://sciruby.codeforpeople.com/sr.cgi/FrontPage for more
information
about people using Ruby for scientific projects.

#5

As with all programming languages there are bindings for Ruby for all of
the
major GUI frameworks.

These days, I would say the most beautifully ruby one is QTruby.  I
don't
know of too many online resources for the project, but there was a PDF
published by the pragmatic programmers on the topic.

#6

Rails is simply a web framework.  Since you've already stated you aren't
interested in Web apps, don't worry about it right now.

Hope that helps.

j.

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

Jeff W.
Austin Z. (Guest)
on 2005-12-21 19:17
(Received via mailing list)
On 21/12/05, Tolga <removed_email_address@domain.invalid> wrote:
> First of all and very first of all, I must state that I am not an
> enemy or a spy :-D
>
> 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?

Whichever one makes you happier.

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

> By the way, I am not a computer scientist and these are the reasons
> why I want to learn Python or Ruby. Please consider them when
> replying:
> 1. I am not a computer scientist.
> 2. I AM interested in artificial intelligence and this is the major
>    reason for me to learn a programming language.
> 3. I am familiar, but not experienced, in BASIC, C/C++, Java, Prolog
>    and Lisp.

There are some people who prefer list comprehensions in Python, but find
it less useful as a "functional" language overall. However, functions in
Python are just that: functions. They are assignable and must be called
with parenthesis:

  def foo:
     ...


  bar = foo # assigns the foo function to bar
  bar()     # calls the foo function

Ruby is fully OO, but is considered by some to have more "functional"
features, but there are no functions (as such) in Ruby. they are all
methods and they are not directly assignable.

  def foo
    ...
  end

  bar = foo # calls the foo method and assigns the result to bar
  bar = method(:foo) # assigns the method foo to bar
  bar[] # calls the foo method
  bar.call # calls the foo method

There are other ways, but that's a distinct difference. Ruby, however,
has blocks with closures and supports lambdas and currying very easily.
This should be easily discovered; Mental is currently writing a series
on doing Monads with Ruby and there's a lot of people doing what is
perhaps best called "higher order Ruby" or "functional Ruby".

> 4. I am *NOT* interested in web programming at all
> 5. Nice GUIs always attract me. It is not mandatory but if Ruby can
>    provide me this (better than Python) I may immediately run to Ruby.

Python probably has the advantage with wxPython; I have seen little
movement in wxRuby lately, but Ruby does have strong support for Tk, the
FOX toolkit (through FXRuby), GTK, QT (there's even a PDF book published
about that). It also has Cocoa support for the Mac and native Win32 MFC
support on Windows through VisualuRuby and SWin.

> 6. And finally, what is "Rails"? Do I have to learn it if I dive into
>    Ruby? Does it necessary for only web?

No, you don't need to learn it. You need to learn Ruby if you want to
really do Rails. Rails is an end-to-end web application stack that
provides web-to-database CRUD application support very inexpensively. It
also supports some level of email handling and other things, but it's
divided into subprojects such that Rails itself is mostly just a
collection of scripts that uses the subprojects to lay out applications
in a very opinionated way.

-austin
James B. (Guest)
on 2005-12-21 19:20
(Received via mailing list)
Tolga wrote:
> First of all and very first of all, I must state that I am not an enemy
> or a spy :-D
>
> 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.

Pick the language that makes you happy, that best fits your brain while
enabling to write good code.  It may be Ruby, it may be Python. It may
be VB.net.  Hard to say; you likely will need to give various candidates
a serious test drive to make your choice.

Ruby and Python have much in common; I've found that Ruby suits me
better.   It makes fewer demands on me.

But take a look at

http://www.ruby-doc.org/RubyEyeForThePythonGuy.html
  and
http://ruby-doc.org/whyruby/

>
> By the way, I am not a computer scientist and these are the reasons why
> I want to learn Python or Ruby. Please consider them when replying:
> 1. I am not a computer scientist.
> 2. I AM interested in artificial intelligence and this is the major
> reason for me to learn a programming language.
> 3. I am familiar, but not experienced, in BASIC, C/C++, Java, Prolog
> and Lisp.

Lisp may have more AI stuff for it.  It's also a nice language.

> 4. I am *NOT* interested in web programming at all
> 5. Nice GUIs always attract me. It is not mandatory but if Ruby can
> provide me this (better than Python) I may immediately run to Ruby.

Ruby offers GUIs.  I don't know if it does better than Python.

> 6. And finally, what is "Rails"? Do I have to learn it if I dive into
> Ruby? Does it necessary for only web?


Rails is a Web app framework.  Strictly optional, and probably not of
interest unless you want to make web sites.


James
--

http://www.ruby-doc.org       - Ruby Help & Documentation
http://www.artima.com/rubycs/ - Ruby Code & Style: Writers wanted
http://www.rubystuff.com      - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com     - Playing with Better Toys
http://www.30secondrule.com   - Building Better Tools
Steffen Mutter (Guest)
on 2005-12-21 20:23
(Received via mailing list)
Am Wed, 21 Dec 2005 08:54:12 -0800 schrieb Tolga:

> One or two weeks ago, I tried Python and loved it.

What exactly did make you feel happy?

> But I also hearing
> ineteresting things about Ruby nowadays. Which language should I use?

Take the language which makes your brain happy and offers you the
opportunity to develop the applications you think the world was waiting
for in a minute.
The documentation of Python's is better (IMHO) so far,if you'd like to
spend a lot of money in books or googkle a dive into python.
If you'd like to go wild in a second I suggest you get the new
pragmatic programmer's 'programming ruby book' v2.

> Oh, yes, this question looks somewhat silly, this is a Ruby group and
> people will tend to give an automatic "Ruby" reply.

Not really. If you like python, stay for a while with it and
get experienced.
Maybe you should choose a commercial IDE like I did with 'komodo' and I
enjoy hacking with it very much, so you still have the opportunity to
develop in different programming languages.

 > By the way, I am not a computer scientist and these are the reasons
why
> I want to learn Python or Ruby.

You don't need to be a computer scientist to write useful programs or
get
geeky.
 Just think about what you really want to code.
If you want to code applications which really need to be object
orientated
you won't miss the easy coding experience offered by ruby.

Regards,
Steffen
Oliver A. (Guest)
on 2005-12-21 20:29
(Received via mailing list)
Hi!

Tolga schrieb:
> 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.

Well, I have been using Python a lot for a long time, and I guess I will
continue to use it in some areas. But recently I gave up my prefudices
about Ruby a view weeks ago. I resisted to use it, cause I thought with
Java and Python I was perfectly equipped for the tasks I have to deal
with. But I kept reading about the fun using ruby, the joy you
experience and the freedom.

Then I decided to redo a web app developed by a contractor of my
company. I looked into the avaiable stuff for my usual programming
languages, but was disappointed one way or another. So, I am mostly a
Ruby learner/new user who was intrigued by Rails. :) But during the last
weeks I did less with Rails but with Ruby, cause I had a lot of fun with
it and some Java/Python tools I have been using, have been reimplemented
in Ruby for fun and to learn it.

> 1. I am not a computer scientist.

Well, then Ruby and Python are good choices.

> 2. I AM interested in artificial intelligence and this is the major
> reason for me to learn a programming language.
> 3. I am familiar, but not experienced, in BASIC, C/C++, Java, Prolog
> and Lisp.

As I have been doing a lot computational linguistics and agent oriented
programming, I would say that you are already perfectly equipped for
this. :)

> 5. Nice GUIs always attract me. It is not mandatory but if Ruby can
> provide me this (better than Python) I may immediately run to Ruby.

Well, I would say, the toolkits you can access are almost the same for
both languages.

> 6. And finally, what is "Rails"? Do I have to learn it if I dive into
> Ruby? Does it necessary for only web?

You said, you won'T do web programming, so rails is not of interest to
you. But ActiveRecord can be interesting as an ORM.

Didn't give you much insight so far, did it? :) Well, I might read
offensive, but in my eyes you haven't asked the right questions, cause
both Python und Ruby will satisfy you based on your questions. My
decision to finally learn Ruby and enjoy using it, are based on only one
thing - the way to express myself and my ideas in the language. I have
been using and loving Python for its clarity in syntax, design and
general appeal. But a lot of this appeal depends on the "there is one
way to do something"-mentality. Once I loved this, cause it opened my
eyes after a long dark age using Perl and C. :)

But it got me a little bit frustrated/bored during the last years to be
honest, and I have been always peeking at the Perl times with a lot of
fancy, compact and creative code. And after my first steps with Ruby I
discovered, that the clean appeal and clarity of Python can be combined
with a artful expression of thoughts in Ruby.

So, my sole point in this is, that Ruby and Python compare quite well.
Each offers some unique features, that the other implements in a
different way, but basically they are more or less equal. But I give you
one advice. Look into both. Spend a weekend with Python and learn it a
little. Do the same with Ruby. And at the end, compare them and choose
the one where you could express your ideas best with. And best means in
my eyes, the way the looks most natural to you. I won't give you the
advice to use Python or to use Ruby, cause I can't decide this for you,
cause I don't know you enough for that.

Best regards,
Oliver

P.S.: Hopefully it is comprehensible what I mean. I am not an native
english speaker, so I have some difficulties to express such things in
english. :)
rcoder (Guest)
on 2005-12-21 21:03
(Received via mailing list)
Tolga,

I'm going to risk several demerits here, and recommend that you look at
Python first, and Ruby second, for the following reasons:

1. Python was initially funded, designed, and documented in large part
as a "teaching" language. The syntax is *extremely* consistent, as are
the core libraries.

2. The free, online documentation for Python is absolutely without
peer. Working just from the main tutorial and langauge reference on the
main Python website, you should have no trouble getting up to speed on
the language.

3. Python still has a more substantial presence in both CS and the
natural sciences, which means more (and somewhat higher-quality)
libraries and books covering the techniques and tools you will need for
AI work. Peter Norvig, very highly-respected AI researcher and
instructor, has even translated his code from "AI: A Modern Approach"
from Lisp to Python.

4. In my experience, the GUI libraries for Python are simply more
mature, better documented, (there's that word again!) and more widely
used that the equivalents for Ruby. If you want rich client interfaces,
using Python will make your life easier.

That being said, the languages are really more alike in capabilities
than different. Also, even with the recent rise of Rails into
popularity, it has been my experience that the Ruby community is
absolutely wonderful to work with; it is seldom you will see a question
be ignored or the asker scorned, even in high-volume channels like this
newsgroup.

Regardless of which language you choose, I wish you the best of luck.

-Lennon
http://rcoder.net/
unknown (Guest)
on 2005-12-21 21:33
(Received via mailing list)
In article <removed_email_address@domain.invalid>,
Tolga <removed_email_address@domain.invalid> wrote:
>By the way, I am not a computer scientist and these are the reasons why
>I want to learn Python or Ruby. Please consider them when replying:
>1. I am not a computer scientist.
>2. I AM interested in artificial intelligence and this is the major
>reason for me to learn a programming language.

We have similar interests, I think.  I've used Ruby for programming
various
machine learning algorithms from genetic algorithms, to support vector
machines.

You should check out the SciRuby site:
http://sciruby.codeforpeople.com/

>3. I am familiar, but not experienced, in BASIC, C/C++, Java, Prolog
>and Lisp.
>4. I am *NOT* interested in web programming at all

Same here.  Or maybe I would say that I have just a little interest in
web
programming.  Rails has put the emphasis on web programming, but Ruby
can be
used for much more than just web programming.

>5. Nice GUIs always attract me. It is not mandatory but if Ruby can
>provide me this (better than Python) I may immediately run to Ruby.

I don't know about 'better', but probably at least as good.

>6. And finally, what is "Rails"? Do I have to learn it if I dive into
>Ruby? Does it necessary for only web?

No, you don't have to learn Rails to learn Ruby (actually, it's more the
other
way around).  Rails is a web programming framework built on Ruby.

Since you tried Python last week, you should give Ruby a try this week.
That'll give you a good idea of which language you find preferable.


Phil
Logan C. (Guest)
on 2005-12-21 21:54
(Received via mailing list)
On Dec 21, 2005, at 12:15 PM, Austin Z. wrote:

> Rails itself is mostly just a
> collection of scripts that uses the subprojects to lay out
> applications
> in a very opinionated way.

Brilliant! Mind if I quote you in sigs in such?
Steve L. (Guest)
on 2005-12-21 22:03
(Received via mailing list)
On Wednesday 21 December 2005 01:22 pm, Steffen Mutter wrote:
> Am Wed, 21 Dec 2005 08:54:12 -0800 schrieb Tolga:
> > One or two weeks ago, I tried Python and loved it.
>
> What exactly did make you feel happy?

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 L.
http://www.troubleshooters.com
removed_email_address@domain.invalid
Austin Z. (Guest)
on 2005-12-21 22:40
(Received via mailing list)
On 21/12/05, Logan C. <removed_email_address@domain.invalid> wrote:
> On Dec 21, 2005, at 12:15 PM, Austin Z. wrote:
> > Rails itself is mostly just a
> > collection of scripts that uses the subprojects to lay out
> > applications
> > in a very opinionated way.
> Brilliant! Mind if I quote you in sigs in such?

Sure, I guess ;)

I'm just taking some of DHH's words and putting them in different
contexts, is all.

-austin
Tolga (Guest)
on 2005-12-21 22:55
(Received via mailing list)
Thank you all for your replies. I think, I've learned how to find my
way ;-D
And I see that I was right when I stated "Python and Ruby have
intellectual communities".
Vivek (Guest)
on 2005-12-22 09:28
(Received via mailing list)
I am not really experienced in python but somehow the  whitespace
indentation  philoplosophyt of python puts me off. I know lots of
people have argued that you get used to it but you got to get started
to get used to it. ;- ) I started ruby because I wanted to learn rails
and I have found it to have all the features of perl and I guess ( I
have read elsewhere) it has the clean syntax and readability of python.

The best part about ruby i like is the ability to dynamically add new
methods with things like "method_missing" ..I think ruby does this kind
of meta-programming in the cleanest way.
Jim F. (Guest)
on 2005-12-22 16:57
(Received via mailing list)
On 12/22/05, Vivek <removed_email_address@domain.invalid> wrote:
> I am not really experienced in python but somehow the  whitespace
> indentation  philoplosophyt of python puts me off. I know lots of
> people have argued that you get used to it but you got to get started
> to get used to it. ;- ) I started ruby because I wanted to learn rails

I've heard this mentioned and assume it is true, but maybe the Python
guys have a way around it...but doesn't Pythons space dependence
preclude one from writing a erb type app with Python?

<?= for i in some_array; do_some_function; end ?>

Or is it that you could do that, but just not write code inline:

<?=
  for i in some_array
    do_some_function
?>

Just wondering.
(Guest)
on 2005-12-22 17:43
(Received via mailing list)
I actually recently tried to pick up Python, by reading 'Dive Into
Python', which got quite good reviews on Amazon.  And I did this mainly
because Ruby is so easy, I thought maybe my brain is getting flabby.
Ruby is Easy.  Almost too easy.  Long story short, after trying to
learn Python syntax, I found that it was not for me.  I was putting in
a lot of effort (perhaps the point of it all), with little return.
Stuff that 'just works' in Ruby seems to take a lot of unnecessary
effort elsewhere.  Ruby seems to have been written to ease the burden
off the programmer, and almost every other language doesn't (in
comparison).  SImilar effort put into Python, or God forbid, VB (or
whatever it's called now), yields so much less.  Perl is a little too
messy, Python not messy enough... Ruby is just right.  It seems to know
what my brain wants in a programming language.
Gene T. (Guest)
on 2005-12-22 18:08
(Received via mailing list)
Tolga wrote:
> First of all and very first of all, I must state that I am not an enemy
> or a spy :-D
>

I don't have much to add, you can google for 750 k hits for "ruby vs
python" and read what people have written on c2.com and artima.com
"your interpreter/VM/lang spec/dev environment is strap-on OO, pass by
reference, weakly typed, weakly lexically scoped, inconsistent API,
writing C extensions sucks and it's slow"

Alex Martelli wrote this, which i think is the best summary to date
http://groups.google.com/group/comp.lang.python/br...

And, just as an observation, i find myself regularly downloading stuff
from CPAN and either rewriting chunks in ruby, or running perl.
Neither python or ruby has anything of that magnitude. (Even after 10+
years of on and off perl use, I find it difficult to read the O-O
stuff,) but ability to read perl will serve you well.
Gene T. (Guest)
on 2005-12-22 18:38
(Received via mailing list)
Gene T. wrote:

>
> Alex Martelli wrote this, which i think is the best summary to date
>

wrong link, sorry:
http://mail.python.org/pipermail/python-list/2005-...
Jeff W. (Guest)
on 2005-12-22 20:32
(Received via mailing list)
Yep, that is a great link.

And pretty darn'd accurate ...

j.

On 12/22/05, Gene T. <removed_email_address@domain.invalid> wrote:
>
>
>


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

Jeff W.
Steve L. (Guest)
on 2005-12-22 20:32
(Received via mailing list)
On Thursday 22 December 2005 11:07 am, Gene T. wrote:
> Tolga wrote:
> > First of all and very first of all, I must state that I am not
> > an enemy or a spy :-D
>
> I don't have much to add, you can google for 750 k hits for "ruby
> vs python" and read what people have written on c2.com and
> artima.com "your interpreter/VM/lang spec/dev environment is
> strap-on OO, pass by reference, weakly typed, weakly lexically
> scoped, inconsistent API, writing C extensions sucks and it's
> slow"

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 L.
http://www.troubleshooters.com
removed_email_address@domain.invalid
Jeff W. (Guest)
on 2005-12-22 20:41
(Received via mailing list)
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. <removed_email_address@domain.invalid> 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.
Martin DeMello (Guest)
on 2005-12-23 01:57
(Received via mailing list)
Tolga <removed_email_address@domain.invalid> 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
baalbek (Guest)
on 2005-12-23 04:10
(Received via mailing list)
Steve L. wrote:
> Remember my thread on end matching, and how complex the answers
> removed_email_address@domain.invalid
>
>

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. Ryan S. (Guest)
on 2005-12-23 04:34
(Received via mailing list)
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 ~
Brian M. (Guest)
on 2005-12-23 06:22
(Received via mailing list)
On 12/22/05, J. Ryan S. <removed_email_address@domain.invalid> 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.
unknown (Guest)
on 2005-12-23 06:49
(Received via mailing list)
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
removed_email_address@domain.invalid

"Ruby for Rails", from Manning Publications, coming April 2006!
http://www.manning.com/books/black
Gene T. (Guest)
on 2005-12-23 07:25
(Received via mailing list)
removed_email_address@domain.invalid 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
unknown (Guest)
on 2005-12-23 07:28
(Received via mailing list)
Hi --

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

> let's not forget
>
> def ClassName::clsmeth(params)
> end

Oh, let's :-)  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
removed_email_address@domain.invalid

"Ruby for Rails", from Manning Publications, coming April 2006!
http://www.manning.com/books/black
Gene T. (Guest)
on 2005-12-23 07:50
(Received via mailing list)
removed_email_address@domain.invalid wrote:

> 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
Jeff W. (Guest)
on 2005-12-23 14:00
(Received via mailing list)
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. <removed_email_address@domain.invalid> 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.
Christian N. (Guest)
on 2005-12-23 16:22
(Received via mailing list)
Jeff W. <removed_email_address@domain.invalid> 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. :-)

> 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 ).
Greg K. (Guest)
on 2005-12-23 16:40
(Received via mailing list)
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!
Jeff W. (Guest)
on 2005-12-23 17:55
(Received via mailing list)
As long as we haven't already gathered up all of the nice people, I
don't
see us having any problems ... ;)

j.

On 12/23/05, gregarican <removed_email_address@domain.invalid> 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.
Jeff W. (Guest)
on 2005-12-23 17:55
(Received via mailing list)
... 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. <removed_email_address@domain.invalid> wrote:
> > aren't going to help you with your homework" ... ( I'm 30+ and have been
>
> > Jeff W.
> --
> Christian N.  <removed_email_address@domain.invalid>  http://chneukirchen.org
>
>


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

Jeff W.
Tom R. (Guest)
on 2005-12-23 18:20
(Received via mailing list)
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.
Christian N. (Guest)
on 2005-12-23 21:03
(Received via mailing list)
Jeff W. <removed_email_address@domain.invalid> 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...
actually is the tail-recursive version. :-)

They could have told you that, of course.
Jeff W. (Guest)
on 2005-12-23 21:39
(Received via mailing list)
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. <removed_email_address@domain.invalid> wrote:
> > Lisp.  I've also been working through "The little schemer" and SICP...
>   http://mitpress.mit.edu/sicp/full-text/book/book-Z...
>
--
"Remember. Understand. Believe. Yield! -> http://ruby-lang.org"

Jeff W.
Jeff W. (Guest)
on 2005-12-23 21:39
(Received via mailing list)
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. <removed_email_address@domain.invalid> 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.
Jacob F. (Guest)
on 2005-12-23 21:51
(Received via mailing list)
On 12/23/05, Jeff W. <removed_email_address@domain.invalid> 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

:)

Jacob F.
Florian F. (Guest)
on 2005-12-23 21:57
(Received via mailing list)
Jeff W. wrote:

>
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"?
Jeff W. (Guest)
on 2005-12-23 21:57
(Received via mailing list)
uh, yeah, that's what I meant ... darn'd quickie code always bites me in
the
butt ...

j.


On 12/23/05, Jacob F. <removed_email_address@domain.invalid> wrote:
> >
> >     sum *= i
>
>       sum *= i
>     end
>     sum
>   end
>
> :)
>
> Jacob F.
>
>


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

Jeff W.
Christian N. (Guest)
on 2005-12-24 12:53
(Received via mailing list)
Jeff W. <removed_email_address@domain.invalid> writes:

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

There are no loops in Scheme.  (while is syntactic sugar.)
unknown (Guest)
on 2005-12-24 14:47
(Received via mailing list)
Hi --

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

>
> removed_email_address@domain.invalid wrote:
>
>> 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

For constant lookup it seems perfectly fine.  I just don't know what
it's doing also being a dot synonym.


David

--
David A. Black
removed_email_address@domain.invalid

"Ruby for Rails", from Manning Publications, coming April 2006!
http://www.manning.com/books/black
Stephen K. (Guest)
on 2005-12-24 20:00
(Received via mailing list)
In message <removed_email_address@domain.invalid>, Steve L.
<removed_email_address@domain.invalid> writes
>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
This topic is locked and can not be replied to.