What's TOTALLY COMPELLING about Ruby over Python?

David Garamond lists at zara.6.isreserved.com
Thu Aug 21 07:52:03 EDT 2003


Jeffrey P Shell wrote:
> Ruby is still more closely related to Perl than it is to Python. 

I think for many people, it all boils down to this. Whoever hates Perl 
will find Python more interesting. Whoever loves Perl, or uses/has used 
Perl, will find Ruby more welcoming.

I for one am a Perl programmer. I have tried to use Python as much as I 
could for several months but just could not get as productive as I am in 
Perl. Hell, I could not even put 'if ... else ...' on the same f*cking 
line! :)

> Ruby
> uses all of those shortcut expressions that I find terrible, like $_.

Ruby _does_ try hard to be a better Perl. This includes providing $_ and 
many other Perl stuffs. However, the more I use Ruby over time, the less 
I use those.

What I like about Ruby is that, despite it brings many features from 
Perl, it still manages to be pretty clean design-wise. The features are 
often layered on top of the OO system (e.g: /.../ is a shortcut for 
creating a Regexp object). And they are all optional to use. Surely one 
is not forced to use it. But I understand that there are people who just 
can't stand the fact that those features _exist_ in the language.

> Ruby uses other punctuation marks to mark what different variables,
> with name, $name, @name, and @@name all being different.  While it's
> nice to differentiate between local, global, instance, and class
> variables, all of these extra punctuation 'shortcuts' get in the way
> of readability. 

Ah, but this improves readability for me. Some people might also argue 
that all those underscores in Python code reduces readability. And how 
many threads are lost for people complaining about having to write 
'self.foo' all the time? ;-)

> Ruby still has too much shell-script nature inside of it.  

Yes. And I love it :)

> in Ruby expression type is command expansion, or `foo`, where foo is a
> shell command.  (You can also use %x, as in %x{echo "Hello There"}). 
> Putting `uname -v` in your code will execute the Unix 'uname' command.
>  The exit status of the command is in the cheerful global variable $?.
>  As a result, I wonder how well Ruby works as an embedded language. 

Not very badly, I think. mod_ruby, eruby, pl-ruby, jruby, ... Though the 
last one is nowhere near usable as Jython right now.

> (NameSpace::Example::CONST or NameSpace::Example.new).  Man, the more
> I write, the more I really appreciate the simplicity of Python.  We
> will do funny things with __underscores__, but even that's pretty
> consistent.

And what's not consistent about :: for namespace separator, $ for global 
vars, @ for class vars, and so on?

> Python also has the nice feature of compiling/caching modules, which
> can speed things up.  I don't know if Ruby re-evaluates all code every
> time you start a Ruby program up, but I haven't really seen an
> equivalent to Python's '.pyc' and '.pyo' (optimized, generated when
> running with the -O option in Python) files.

This is a purely implementation issue, not the issue with the language 
itself. Currently Ruby does not have a VM yet, so it does not have 
bytecode compilation. But it will in Ruby 2.0. The current 
implementation of Ruby (Ruby 1.x) is admittedly not very fast, but it's 
already much faster & efficient than Python for some things (like 
creating and destroying objects/classes).

> Ruby does have some nice things going for it, and I think that people
> looking for a good object oriented Perl would be happy with it. 
> Personally, I think that Python is more mature, has better design
> influences (Modula and ABC instead of Perl and Smalltalk). 

Ruby is also largely influenced by LISP.

> def mult(n, fact)
>   n * fact
> end
> 
> the last statement in an expression is what's returned.  You *can* use
> a return statement.  But it's nice that Python always requires it

This is also one of the thing I hate in Python :)

-- 
dave







More information about the Python-list mailing list