Why Ruby over Python?

Hi --

···

On Sun, 9 Jul 2006, Troy Denkinger wrote:

As a longtime Perler, I dislike Python's significant whitespace. That's why
I could never go for it. Ruby just feels right to me. I enjoy writing it
and it feels liberating when I do.

I still like Perl, but Ruby is quickly winning me over.

Let's be clear about this, though: people *are* allowed to like and
use more than one language :slight_smile: This is a point that sometimes gets
obscured in these "winner-take-all" language comparison discussions.

David

--
  "To fully realize the potential of Rails, it's crucial that you take
    the time to fully understand Ruby--and with "Ruby for Rails" David
       has provided just what you need to help you achieve that goal."
       -- DAVID HEINEMEIER HANSSON, in the foreword to RUBY FOR RAILS.
  Complete foreword & sample chapters at http://www.manning.com/black\!

khaines@enigo.com wrote:

RoR is irrelevant to it.

Ruby is love.
Python is bondage.

Uh ... love ... bondage ... uh ... never mind

<ducking>

···

--
M. Edward (Ed) Borasky

http://linuxcapacityplanning.com

Matt Lawrence wrote:

···

On Sat, 8 Jul 2006 howachen@gmail.com wrote:

Besides ROR, can you give me a reason why perfer ruby instead of
python?

Did you see the lovely young ladies (I hope you know who you are) at
the last RubyConf?

And ... which would *you* give a lovely young lady -- a ruby or a
dangerous reptile?

:slight_smile:

--
M. Edward (Ed) Borasky

http://linuxcapacityplanning.com

Michael Greenly wrote:

unknown wrote:

Besides ROR, can you give me a reason why perfer ruby instead of
python?

seems to many users, they are very similar in nature...

such as

1. non C or Java style syntax
2. focus on codes readability, not like Perl
3. ..

They are both excellent so you will not be unhappy with either.

There are differences in development philosophy among the two communities, though. For example, both Python and Ruby allow running code to alter existing classes, including core classes (though I do not know if they are equivalent in options and effect).

The Python community is likely to look down on this, calling it "monkey patching." In the Ruby community this is simply one of many techniques for building applications and is pretty common.

Ultimately the language is yours to use as you please, but it helps to have a community with a sense of design and development that matches your own, one that will help you grow in the direction you prefer.

The significant whitespace was really the decider for me personally.

Ruby has significant white space, too. But no significant indentation (or, as I tend to think of it, "static indentation.")

···

--
James Britt

"A language that doesn't affect the way you think about programming is not worth knowing."
   - A. Perlis

I love Ruby because I can do this:

class Integer
  def even?
    ( self % 2 ) == 0
  end
end

puts 3.even?
puts 28.even?

-R
"Quis custodiet ipsos custodes?"

dblack@wobblini.net wrote:

···

Hi --

On Sat, 8 Jul 2006, howachen@gmail.com wrote:

> Besides ROR, can you give me a reason why perfer ruby instead of
> python?
>
> seems to many users, they are very similar in nature...
>
> such as
>
> 1. non C or Java style syntax
> 2. focus on codes readability, not like Perl
> 3. ..

I can give you the answer in my case: love. I fell in love with the
Ruby language, and subsequently with the Ruby culture and community.
That gives you a much more lucid, rigorous account of my experience
than anything I can say about blocks, significant whitespace, or other
language features possibly could.

David

--
  "To fully realize the potential of Rails, it's crucial that you take
    the time to fully understand Ruby--and with "Ruby for Rails" David
       has provided just what you need to help you achieve that goal."
       -- DAVID HEINEMEIER HANSSON, in the foreword to RUBY FOR RAILS.
  Complete foreword & sample chapters at http://www.manning.com/black\!

khaines@enigo.com writes:

Ruby is love.
Python is bondage.

I choose love.

Vanilla!

SCNR.

···

Kirk Haines

--
Christian Neukirchen <chneukirchen@gmail.com> http://chneukirchen.org

Marcelo wrote:

What about GUI programming?
  

A Pythonista will immediately counter with, "What about Python/TkInter?" :slight_smile:

···

--
M. Edward (Ed) Borasky

http://linuxcapacityplanning.com

Marcelo wrote:

What about GUI programming?

http://www.trug.ca/Ruby_GUI_Toolkits

lopex

Well, we've got rdoc. What specific python doc feature do you miss?
Maybe being able to type "help( some_obj.some_method )" at the
interactive prompt?

Personally, I didn't like the Python way of putting doc strings
*below* the thing they were documenting... always seemed upside-down.

···

On 7/10/06, Tim Pease <tim.pease@gmail.com> wrote:

[snip]

What I do like about Python is how the documentation is built right
into the language. That is the biggest feature I wish Ruby had. That
and Python's speed -- long live YARV.

For me it's not so much the shelling out as it is invoking some Ruby
methods that deal with files, directories, etc. or trying to use a
setup.rb Ruby routine that is trying to parse through the Windows
directory structure. Unfortunately some Ruby projects are still
maintained with a Linux focus and the support for Windows is lacking. I
have tried to manually "rig" fixes so that they can work with my
Windows platform but after an hour or so of futile effort I just switch
over to a Python alternative that does the same thing. Examples are
LDAP, Qt, and a few others. This was about a year ago so things might
have improved since then. YMMV...

Tim Hammerquist wrote:

···

Jeffrey Schwab <jeff@schwabcenter.com> wrote:
> The one thing that sticks in my craw about Ruby is that
> File::Separator is a forward-slash ('/') on Windows. This is just
> wrong, and it means I have to replace the slashes with back-slashes
> manually before passing file paths to command-line programs. If you
> pass a Windows program a path like /some/path, the program will try
> to interpret path elements as switches. It's almost the equivalent
> of having File::Separator be a hyphen ('-') on Unix.

Aside from the obvious argument that making filesep '\' in DOS was the
first mistake, I'm curious what command-line programs are useful
enough that you shell out from the language you're writing in?

Tim Hammerquist

Doug H wrote:

···

howachen@gmail.com wrote:
> Besides ROR, can you give me a reason why perfer ruby instead of
> python?
>
> seems to many users, they are very similar in nature...
>
> such as
>
> 1. non C or Java style syntax
> 2. focus on codes readability, not like Perl
> 3. ..

Go ask this same question over on comp.lang.python and you'll see why
you might prefer ruby.

Funny you ask:
http://groups.google.ca/group/comp.lang.python/tree/browse_frm/thread/40d8d11e12cb00ba/12306d4d9b0ce50c?rnum=11&q=ruby+or+python&_done=%2Fgroup%2Fcomp.lang.python%2Fbrowse_frm%2Fthread%2F40d8d11e12cb00ba%2F7256adbbc7f79afe%3Fq%3Druby+or+python%26rnum%3D1%26#doc_74bfb0743eff1367

Jean-Marc

If you have a question, send e-mail with the body
  "help" (without quotes) to the address ruby-talk-ctl@ruby-lang.org;
  help=<mailto:ruby-talk-ctl@ruby-lang.org?body=help>

···

On 7/12/06, j c theriot <jctheriot@yahoo.com> wrote:

Admin -

  having trouble unsubscribing from this list,
where/how do I send unsubscribe message?

Thanks

brad tilley wrote:

This may be a trivial reason to most people, but it makes a huge
difference to me. I find it _much_ easier to turn .rb scripts into
standalone .exe executbales on Windows. I've used Python's py2exe and it
works OK, but Ruby's rubyscript2exe is far better and far easier to use.

I absolutely agree! Erik Veenstra's done a fantastic job developing,
maintaining, documenting, and supporting Tar2Rubyscript and
Rubyscript2Exe, and that's a major reason why I am developing more apps
in Ruby than in Python (with which I have more experience).

Mully

···

--
Posted via http://www.ruby-forum.com/\.

Python indeed doesn't have an #each method to iterate over a container
class and pass the elements into a block as is the case with Ruby. I
think this is because Ruby borrowed from Smalltalk with the do, block,
each, etc. aspects of the language. And Python did not.

There is a next( ) method in Python that will advance to the next
element of a container class. Here's a reference -->
http://docs.python.org/lib/typeiter.html\. From there you could _sort
of_ create your own block using Python lambdas to mimic things to a
point...

bitdoger2@yahoo.com wrote:

···

newbie asks: is it true that python does NOT support containers simply
like ruby does?
ie.
a=<< an array container
a<<[0,1,2]
a<<{"me"=>"i think","you"=>"you think"}
and then use .each iterater to process this container....
howachen@gmail.com wrote:
> Besides ROR, can you give me a reason why perfer ruby instead of
> python?
>
> seems to many users, they are very similar in nature...
>
> such as
>
> 1. non C or Java style syntax
> 2. focus on codes readability, not like Perl
> 3. ..

I don't know what you mean "simply". Here goes the code:

a =
a += [1, 2, 3]
# if you would append the list instead of three numbers,
# it would be a.append([1, 2, 3])
a.append({"me": "i think", "you": "you think"})

for i in a:
    print i

That's all.

Marcelo

bitdoger2@yahoo.com wrote:

···

newbie asks: is it true that python does NOT support containers simply
like ruby does?
ie.
a=<< an array container
a<<[0,1,2]
a<<{"me"=>"i think","you"=>"you think"}
and then use .each iterater to process this container....
howachen@gmail.com wrote:
> Besides ROR, can you give me a reason why perfer ruby instead of
> python?
>
> seems to many users, they are very similar in nature...
>
> such as
>
> 1. non C or Java style syntax
> 2. focus on codes readability, not like Perl
> 3. ..

QOTD +1!!!!

mathew wrote:

···

Doug H wrote:
> howachen@gmail.com wrote:
>> Besides ROR, can you give me a reason why perfer ruby instead of
>> python?
>
> Go ask this same question over on comp.lang.python and you'll see why
> you might prefer ruby.

Also, try running Python and typing quit. Then try exit.

Then run irb, and try quit, exit and Ctrl D.

That's my favorite example of the difference between the Ruby Way and
the Python Way.

mathew
--
      <URL:http://www.pobox.com/~meta/&gt;
My parents went to the lost kingdom of Hyrule
    and all I got was this lousy triforce.

Jamey Cribbs wrote:

James Britt wrote:

Besides ROR, can you give me a reason why perfer ruby instead of
python?

The Ruby community is better-looking.

And more modest.

And more funny. :slight_smile:

···

howachen@gmail.com wrote:

M. Edward (Ed) Borasky wrote:

Yes, indeed, learning multiple languages does help you grow, provided
they aren't too similar. There's a note about that on someone's blog --
give me a day or so and I can track it down. But briefly, he claimed --
and I somewhat agree -- that there are two broad classes of language.
  

···

--
M. Edward (Ed) Borasky

http://linuxcapacityplanning.com

Indeed, I am a dynamic languages enthusiast. Perl specialist by historical accident, that's the one I learned the firt. But very happy to code in either Python or Ruby. My Perl module Acme::Pythonic is kind of a joke about these "dualities".

-- fxn

···

On Jul 8, 2006, at 19:08, dblack@wobblini.net wrote:

As a longtime Perler, I dislike Python's significant whitespace. That's why
I could never go for it. Ruby just feels right to me. I enjoy writing it
and it feels liberating when I do.

I still like Perl, but Ruby is quickly winning me over.

Let's be clear about this, though: people *are* allowed to like and
use more than one language :slight_smile: This is a point that sometimes gets
obscured in these "winner-take-all" language comparison discussions.

*much* shorter answers :wink:

···

On 7/8/06, M. Edward (Ed) Borasky <znmeb@cesmail.net> wrote:

vasudevram wrote:
> Hi,
>
> I'm sticking my neck out here a bit, since I'm relatively new to Ruby,
> but gonna do it anyway ... :0) [I do have a good amount of experience
> in other languages like Java, C, Python]. More knowledgeable Rubyists,
> feel free to flame away at what I say below :slight_smile: I know I'll learn
> something from it anyway.
>
Not so much flames as challenges ...
> Reason 0: First of all, its not necessarily a matter of preferring Ruby
> *over* Python. Its not an either-or situation at all - unless you want
> to make it one. Its quite possible to learn and work with more than one
> language at the same time, or at least in a staggered/parallel manner.
> Many top developers are of the view that learning and using more than
> one language is beneficial, helps you grow as a programmer.
I have found that switching languages rapidly, frequently, even in a
"staggered/parallel" manner is for the most part counter-productive.
Programming in *any* language is an activity that requires a mix of
intense focus on the programming tasks *and* an intensely active
communication in a spoken human language with customers and colleagues.
Add multiple programming languages and you lose focus.

Occasionally a project will need multiple languages. I've found those go
slower and are more difficult than projects where you can wallow in your
knowledge of a single language and a single application domain. I pity a
programmer who has to write a Ruby - FORTRAN bridge that is called by a
Java ERP application for an engineering firm located in Quebec. :slight_smile:

Yes, indeed, learning multiple languages does help you grow, provided
they aren't too similar. There's a note about that on someone's blog --
give me a day or so and I can track it down. But briefly, he claimed --
and I somewhat agree -- that there are two broad classes of language.

There's the "Algol Family", into which class C/C++, Java, Python, Ruby,
Perl, etc. fall, and there's the "Lisp Family". If you're like most of
us, you spend most of your time in the Algol family. His point was that
you grow more if you learn a Lisp family language than if you learn
another Algol family language.

Incidentally, where I disagree is that I think there are six families:

1. Macro assemblers
2. Algol
3. Lisp
4. APL
5. Forth
6. Smalltalk

One of the things that's attractive to me about Ruby is that it contains
features from most of the six. I haven't found much of APL or Forth, but
there are clearly influences from Algol, Lisp, Smalltalk and macro
assembler.
> Reason 1: Ruby is more object-oriented than Python.
>
Well ... Ruby objects were there from day one, and they resemble
"classical" object concepts like those in Smalltalk, C++ and Java, but I
don't think *today's* Python is "less object-oriented" than *today's*
Ruby, nor do I think Ruby is "more object-oriented" than R, Lisp or
Scheme.
> Reason 2: The Principle of Least Surprise. You can, to a good extent,
> almost figure out how parts of the language / syntax work, after you've
> learnt a bit of it. Read the Pickaxe and other Ruby books and the docs
> to see more on what this means.
> I've been writing some Ruby code and can attest to it.
>
I haven't found Ruby code all that obvious to a newcomer. I've been
programming a long time, and I have a programming style that evolved
from macro assembler to FORTRAN to Perl to R, with influences from Lisp,
FORTH and Java.

Part of it is that I'm very much more familiar and comfortable with
functional programming than I am with object-oriented programming. In my
younger days, I was actually one of those people who went around on long
tirades declaiming that Functional Programming was the one true way. :slight_smile:
I thought pure functional languages had a lot going for them. I still do.

I spent about three hours last night trying to understand Hal Fulton's
well-crafted example of metaprogramming that reads CSV files. I know it
will make sense to me eventually, but it didn't after three hours. I
know it's "good code", I know it's "elegant code", I know it's an
example of the wonders of Ruby, and I know it works. But I still don't
know why. :slight_smile:
> Reason 3: No indentation rules like in Python. Just open the logical
> construct like if or while with its corresponding keyword ("if" /
> "while"), close it with "end". Though I'm an experienced developer and
> a very good typist, Python's syntax rules recently almost drove me mad,
> trying to track down an elusive bug that was related to indentation.
> The rules of indentation themselves are straightforward enough. The
> problem arises when you accidentally, say, mix spaces and tabs, or, if
> you're not using tabs (which is probably better), put in one more or
> less space - stuff like that. This was not the problem in my case,
> since I consistently use tabs. The problem arose - I think - because I
> was switching text editors (Metapad and GVim on windows) at times in a
> coding session. This somehow led to the changing of some tabs to
> spaces. Hard to detect visually in a Windows style editor like Metapad.
> Using the ":se list" option in GVim can help, but it still takes time
> to track down and change all those spaces back to tabs. One can argue
> away that one should not change editors in the middle of a session,
> etc., but the point is that this problem simply would not happen in
> Ruby, even if you switch editors midway.
>
Well ... there are language-specific IDEs for Python. If I were
planning/required to learn Python, I'd probably use Leo. I've got Leo
and if I can get it integrated with the languages I do use, Perl, R and
Ruby, I'll give it a shot. And there are language-specific IDEs for
Ruby. But don't *real* programmers use Emacs?

<ducking>

Actually, I've never bothered to learn Emacs. It had a (justified)
reputation as a memory hog, so I learned vi. I'm pretty sure GNU Emacs
is no longer a memory hog, but I'm so firmly down the "vim" path that
Emacs seems like a distraction.

--
M. Edward (Ed) Borasky

http://linuxcapacityplanning.com

--
Deux choses sont infinies : l'univers et la bêtise humaine ; en ce qui
concerne l'univers, je n'en ai pas acquis la certitude absolue.

- Albert Einstein