What's TOTALLY COMPELLING about Ruby over Python?
jwdillworth at yahoo.com
Tue Aug 19 17:53:19 CEST 2003
OK, I'll bite.
(sorry, post got long too)
DISCLAIMER: I don't have time at work to read this entire thread.
DISCLAIMER 2: Something I might find totally compelling, someone else
might think is trivial, or even stupid, to each his own.
I've used Python for a couple of years at my job for many projects,
including CGI's, "glue" scripts, a CVS tool, and one or two GUI apps
to allow internal users to stop asking me to do things I was doing
for them with quick one-off shell-scripts.
I read the "Pick Axe" book. My one-sentence impression of Ruby
has been: "Prettier core language (a few significant warts have
been fixed as of 1.8), needs more stable libraries."
I find the "Prettier core language" compelling.
For example, say you want a static method:
def static_meth(a, b):
return a + b
static_meth = staticmethod(static_meth)
I don't like that something has to be done at the end of the
method to make it static. It could be bad if it were done at
the end of the class, away from the method, someone might think
the omission of self was an error, correct it, and then you'll
have a problem.
In Ruby it's:
def A.static_meth(a, b)
return a + b
I like that Ruby's interpreter enforces specific naming rules for
constants, globals, instance variables, etc. This shows in the
Ruby libraries. In Python's libraries classes might be upper or
lower case (lowercase denotes those implemented in C), Ruby has
had no reason to distinguish what classes are implemented in, since
they're all treated the same (ie you can inherit, and you always
could, in Python this is a recent improvement).
Ruby's licensing seems to be a mess. Some of the interpreter
source is LGPL, some is Artistic or GPL (letting you choose). Not
a problem in most cases, but I like Python's licensing much better.
Ruby's C API looks cleaner and more comprehensible to me. Though
Boost.Python looks like it wraps Python's C API just as cleanly...
I don't see any mature/stable GUI frameworks I like for Ruby. I
think they just started wxRuby. I don't like Fox Ruby's windows
look on Linux. Tk is kinda OK, but I think it was kind of silly
that they prefixed classes with a Tk, when Ruby supports
namespaces perfectly well via modules (maybe fixed in 1.8?). As for
Ruby GNOME/GTK, I don't trust GTK+ on windows (I want a GUI
toolkit that works on Windows, Linux, and Mac OS X if possible).
Ruby's not using whitespace to delimit blocks may help you
avert civil war at your shop depending on how people view the
Ruby 1.8 has some nice improvements, but there are no books
explicitly on 1.8 yet, and I haven't seen any signs that any
are coming (yet).
Ruby's FTP library doesn't work with file-like objects (maybe
fixed in 1.8?), it works with file names... forcing you to
write to files on disk instead of perhaps dynamically generating
stuff you send to an FTP server.
Operator overloading syntax is nicer, I find:
easier on the eyes than:
def __add__(self, other):
Ruby's blocks make using threading and forking pretty nice:
t = Thread.new do
# ... code to execute in another thread
# ... fork and run this code
I like this better than (if memory serves):
# ... do stuff in a thread
pid = os.fork()
if not pid:
# ... do stuff in fork here
sys.exit() # unless you want the child to carry on past the if...
I've been noticing a lot more Ruby web-sites lately. Either
I haven't been paying attention, or Ruby has gained some inertia.
Also, Ruby's collection methods are really a sight to behold.
Over a weekend, I wrote some scripts which chained together like
half a dozen method calls to manipulate a collection, and everything
worked the first time, like I expected. This happens in Python too,
but I think it happens slightly more in Ruby (maybe 90% of the time
compared to 80% w/Python).
I'm toying with the idea of writing a game engine. For this, I'm
almost certain to embed Ruby for AI scripting... since library
issues seem moot in an embedding case.
For prototyping and embedding in another app... and possibly for
"glue" scripts... Ruby would be my first choice. For large GUI
apps or maybe large web apps, I'm not convinced yet.
--- "Brandon J. Van Every" <vanevery at 3DProgrammer.com> wrote:
> I'm realizing I didn't frame my question well.
> What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump
> up in your chair and scream "Wow! Ruby has *that*? That is SO FRICKIN'
> COOL!!! ***MAN*** that would save me a buttload of work and make my life
> sooooo much easier!"
> As opposed to minor differences of this feature here, that feature there.
> Variations on style are of no interest to me. I'm coming at this from a C++
> background where even C# looks like an improvement. ;-) From 10,000 miles
> up, is there anything about Ruby that's a "big deal" compared to Python?
> One person mentioned Japanese documentation. I'm sure that's Totally Kewl
> to the Japanese....
> Cheers, www.3DProgrammer.com
> Brandon Van Every Seattle, WA
> 20% of the world is real.
> 80% is gobbledygook we make up inside our own heads.
More information about the Python-list