Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   Ruby and Python, questions (not a flamewar!) (http://www.velocityreviews.com/forums/t837316-ruby-and-python-questions-not-a-flamewar.html)

Drew Olson 01-18-2007 03:00 PM

Ruby and Python, questions (not a flamewar!)
 
I've been using ruby for the past 6 months and I must say I am extremely
impressed. I find it a joy to write and I even find myself making
excuses to throw together simple scripts at work. I'm also teaching
myself rails and enjoying the experience as well.

At the same time, I'm looking at Python because I think it's also an
important language to know/understand today. However, the more I look at
Python the more I am convinced that ruby is just better. Syntax-wise,
language vision, design philosophy, I like them all from the ruby side
better.

So, I am kind of confused as to why Python is so mainstream and ruby
still seems so fringe. Apps like YouTube are written in Python and
powerful organizations like NASA, Google, etc. are using Python as well.
So basically, here are my questions:

1) I've read that Python is faster than ruby. How is this possible if
they're both interpreted languages written in C? Is it marginally or
substantially faster? Will this change with the release of YARV? Even if
ruby becomes faster with YARV, wouldn't this mean that the underlying
language, before producing the bytecode, is slower than Python?

2) Why are many mainstream organizations using Python rather than ruby?
Is it simply an age issue (Python has been around longer)? Is it a
performance issue? Is this changing currently?

3) Python seems to be quite prevalent within Linux distros as config
scripts...how did they gain this foothold? Why not ruby for standard
Linux config scripts?

Thanks so much for any answers you all have. I can only hope that ruby
will begin to rival Python in the "mainstream" (whatever this means).

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


M. Edward (Ed) Borasky 01-18-2007 03:28 PM

Re: Ruby and Python, questions (not a flamewar!)
 
Drew Olson wrote:
> 1) I've read that Python is faster than ruby. How is this possible if
> they're both interpreted languages written in C? Is it marginally or
> substantially faster? Will this change with the release of YARV? Even if
> ruby becomes faster with YARV, wouldn't this mean that the underlying
> language, before producing the bytecode, is slower than Python?
>

I believe the Java Virtual Machine Ruby (JRuby) and the JVM Python
(Jython) are competitive in performance. And I expect YARV to be
competitive with any other language -- despite what some people say,
there's nothing in the syntax or semantics of Ruby that forces a Ruby
implementation to be *significantly* slower over all than other
languages. It's purely a case of how clever you have to be when you
implement the language run-times, compilers and interpreters.
> 2) Why are many mainstream organizations using Python rather than ruby?
> Is it simply an age issue (Python has been around longer)? Is it a
> performance issue? Is this changing currently?
>
> 3) Python seems to be quite prevalent within Linux distros as config
> scripts...how did they gain this foothold? Why not ruby for standard
> Linux config scripts?
>

1. Ruby started out a little later than Python, but the main reason
Python is so much better known and more widely adopted is that Ruby was
developed in Japan, and English-language documentation was pretty much
unavailable until Ruby 1.6.

2. The question you *aren't* asking is "Why Python and not Perl?" And
the answer is that Python is a lot easier to learn and use than Perl. :)
> Thanks so much for any answers you all have. I can only hope that ruby
> will begin to rival Python in the "mainstream" (whatever this means).
>

I'm not sure this hope is by any stretch of the imagination shared by a
large number of Rubyists. For one thing, it's unrealistic to expect
major rewrites out of *any* current language -- Python, Perl, PHP, C++,
Java, etc. are well-established, *living* languages with millions of
lines of working and mostly maintainable code, IDEs, etc. What I hope
and wish for as a Rubyist is simply that Ruby gets its proper share of
*new* code, and I think that's happening. I'm not writing much new Perl
these days, and I don't know any of the other mainstream general purpose
languages well enough to do more than attempt to read the code.


--
M. Edward (Ed) Borasky, FBG, AB, PTA, PGS, MS, MNLP, NST, ACMC(P)
http://borasky-research.blogspot.com/

If God had meant for carrots to be eaten cooked, He would have given rabbits fire.



Mark Haliday 01-18-2007 04:07 PM

Re: Ruby and Python, questions (not a flamewar!)
 
Drew Olson wrote:

> So, I am kind of confused as to why Python is so mainstream and ruby
> still seems so fringe. Apps like YouTube are written in Python and
> powerful organizations like NASA, Google, etc. are using Python as well.


Python has a large library. Ruby's library is good and growing but it
simply doesn't compare to Python's at this point. At times I want to do
something in Ruby and I end up having to do it in Python simply because
the library pieces I'm looking for exist in Python and not in Ruby. So
I learned both.


>
> 1) I've read that Python is faster than ruby. How is this possible if


Python for the most part is faster. It's had more time to mature than
Ruby and the way the code is interpreted if I recall correctly is
different and Python currently has the edge there. Currently, Python
goes to bytecode and Ruby doesn't I believe. YARV should get Ruby on
par with Python or perhaps surpass it in speed - time will tell.


> 2) Why are many mainstream organizations using Python rather than ruby?
> Is it simply an age issue (Python has been around longer)? Is it a
> performance issue? Is this changing currently?


Python was better known in the mid to late 90's, especially in North
America.

> 3) Python seems to be quite prevalent within Linux distros as config
> scripts...how did they gain this foothold? Why not ruby for standard
> Linux config scripts?


Again, Python was here first, had good docs and a strong library. It
got a foothold first.

Had DHH written Rails for Python I think we'd see Python now the defacto
king of scripting languages. That didn't happen obviously. Rails is
Ruby's killer framework and I think has done more to promote Ruby than
any other thing.

Both Python and Ruby are great languages and both are going to keep
moving forward. The only one I see in troubled waters is Perl. I think
they've kinda hurt themselves by betting the farm so to speak on Perl 6
which has yet to materialize in a fully working form. Many people gave
up waiting and moved to Ruby or Python instead.

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


r 01-18-2007 06:12 PM

Re: Ruby and Python, questions (not a flamewar!)
 
Drew Olson wrote:
> I can only hope that ruby
> will begin to rival Python in the "mainstream" (whatever this means).


I think the battleground is web apps. Right now you can leverage all
the RoR content that's directed at J2EE programmers, but you can't
hope to win a war of ideology yourself. The platform chosen seems to
determine what problems will be solved, from there you can Do The
Simplest Thing That Could Possibly Work, but it's not clear to me that
the choice of platform is anything more than an ideological struggle
where decisions are made, prior to the application of say Agile or
Design Heuristics, that determine all the problems in advance.

It would be nice if Do The Simplest Thing That Could Possibly Work, or
a normal conversation about what we can agree on, determined that Ruby
should be the language.

Maybe it would sound like: Look, Python has this weird indented
syntax and a bolted-on object model that creates an interest gap for
Java programmers. PHP is simply an unacceptable mess to Java
programmers. On the other hand there is definite interest in Ruby from
Java and dotNet programmers, due to 1) the base language Ruby actually
able to do something useful by itself, 2) RoR and 3) the basically
unacceptably complex and expensive definitions those popular compiled
languages with their do-nothing syntax have for The Web App.

-r


Alex LeDonne 01-18-2007 06:20 PM

Re: Ruby and Python, questions (not a flamewar!)
 
I'll address the one with which I have first-hand experience...

On 1/18/07, Drew Olson <olsonas@gmail.com> wrote:
> 2) Why are many mainstream organizations using Python rather than ruby?
> Is it simply an age issue (Python has been around longer)? Is it a
> performance issue? Is this changing currently?


In some organizations, the answer is "inertia". It's more than just
age; it's the combination of age, existing expertise, installed base
of code, and concern about maintainability (however unfounded - I've
found that Python programmers have no problem reading, understanding,
and maintaining ruby code). But as more agile and startup companies
start using ruby, two things will happen: ruby talent becomes
easy/obvious to find, and some of those companies become "mainstream".
And then, who knows?

-Alex


Michael P. Soulier 01-18-2007 06:45 PM

Re: Ruby and Python, questions (not a flamewar!)
 
On 1/18/07, Drew Olson <olsonas@gmail.com> wrote:
> So, I am kind of confused as to why Python is so mainstream and ruby
> still seems so fringe. Apps like YouTube are written in Python and


In my opinion, it's quite simple. Documentation.

With Python, the documentation is excellent, and it is very simple to
find docs for older versions of Python which you are likely using, as
projects stay on a given version for large amounts of time.

By constrast, the available Ruby documentation provided for free by
the project is pitiful. It is difficult to start without good docs,
when the alternatives have such excellent documentation.

I work on Ruby and Python projects, and I'm always wincing when I work
on Ruby after just working on Python. I do not like the Python
language as much, but the docs make my job easier than the digging and
digging that I need to do with Ruby.

Yes, that even includes buying the Pickaxe book, which should be an
optional step to using the language, btw, not a required one.

Love the language. It really needs a better library reference and
manual than what is currently available, and it needs to be available
for all previous versions of the language that someone might be using.

Sorry to rant, but it's a sore-point for me, because I do love the
language. Unfortunately I don't have copious free time to help fix the
problem. I can use the language or I can document it, but I can't do
both.

Mike
--
Michael P. Soulier <msoulier@digitaltorque.ca>
"Any intelligent fool can make things bigger and more complex... It takes a
touch of genius - and a lot of courage to move in the opposite direction."
--Albert Einstein


Giles Bowkett 01-18-2007 07:03 PM

Re: Ruby and Python, questions (not a flamewar!)
 
> 1) I've read that Python is faster than ruby. How is this possible if
> they're both interpreted languages written in C? Is it marginally or
> substantially faster? Will this change with the release of YARV? Even if
> ruby becomes faster with YARV, wouldn't this mean that the underlying
> language, before producing the bytecode, is slower than Python?


Python isn't really an interpreted language in the sense that Ruby is.
Python scripts compile to Python bytecode, and it's the bytecode --
not the script itself -- which the interpreter runs. This is an
intermediate zone between a pure interpreted language like Ruby, and a
pure compiled language like C. The Python bytecode interpreter is
generally faster than regular scripting language interpreters, but
slower than C. However, it's not always very much slower. Lots of
low-level operations, like GUI stuff and I/O stuff, are handed off
directly to C code within the interpreter, and run pretty quickly
because of that. Long story short, Python's unusually fast for a
scripting language.

> 2) Why are many mainstream organizations using Python rather than ruby?
> Is it simply an age issue (Python has been around longer)? Is it a
> performance issue? Is this changing currently?


Ruby is of a comparable age, but it started in another country, a
distant country whose language is so different it cannot really be
translated literally, and Python's performance edge is signficant.

> 3) Python seems to be quite prevalent within Linux distros as config
> scripts...how did they gain this foothold? Why not ruby for standard
> Linux config scripts?


Same as number 2.

Basically, the advantage is the bytecode interpreter, and that Ruby
came from outside the West. Faster performance plus lower barriers to
adoption equals more users.

(Or at least, more users for now. Ruby books are outselling Python
books today, according to O'Reilly.)

--
Giles Bowkett
http://www.gilesgoatboy.org
http://gilesbowkett.blogspot.com
http://gilesgoatboy.blogspot.com


Michael Greenly 01-18-2007 07:11 PM

Re: Ruby and Python, questions (not a flamewar!)
 
Mark Haliday wrote:

> Had DHH written Rails for Python I think we'd see Python now the defacto
> king of scripting languages. That didn't happen obviously. Rails is
> Ruby's killer framework and I think has done more to promote Ruby than
> any other thing.


I don't share this opinion. I think Ruby (maybe more slowly) would of
continued to grow regardless of what happened with Rails. A few years
back (well before rails) I decided to add a more dynamic/scripting
language to my toolbox. I spent several months with Python and then
tried Ruby and never looked back. The same things that made DHH choose
Ruby would of kept grabbing the attention of other programmers even if
he hadn't noticed it.

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


gga 01-18-2007 08:14 PM

Re: Ruby and Python, questions (not a flamewar!)
 
Drew Olson wrote:
>
> 1) I've read that Python is faster than ruby. How is this possible if
> they're both interpreted languages written in C? Is it marginally or
> substantially faster? Will this change with the release of YARV? Even if
> ruby becomes faster with YARV, wouldn't this mean that the underlying
> language, before producing the bytecode, is slower than Python?
>


Ok, this is subjective, so take it with a grain of salt, but...
Yes. Standard C Python is (slightly) faster for mathematical
operations and the like (about 10-20%). It is a tad slower, imo, for
object inheritance (about 5-10%) and, albeit I have never quite
benchmarked, I would bet it is also slower for string operations (as
Python's strings are immutable, unlike Ruby's).
YARV, as it already appears in 1.9, will make Ruby roughly as fast as C
Python (some preliminary tests are still a tiny little bit faster in
Python, others are already faster in YARV). YARV does not look like it
will make Ruby faster than Python+Psyco, thou.
While the alioth shootout is often criticized for its unfairness (and
there is some truth to that, particularly with the python benchmarks
where I've often seen some questionable code) and their benchmarks lean
heavily on measuring just numerical performance, the overall results of
still show relatively correct trends in performance.
See:
http://shootout.alioth.debian.org/gp...ron&lang2=yarv
http://shootout.alioth.debian.org/gp...hon&lang2=yarv
http://shootout.alioth.debian.org/gp...yco&lang2=yarv

YARV, however, appears to me a slightly ahead of the game in terms of
making Ruby truly multi-threaded. The Python GIL (global lock) seems
like it is a big thorn into the design of the C Python interpreter.
Personally, I don't think performance is a strength of Python at all
anymore. In terms on scripting language performance, LuaJIT has left
YARV, CPython+Psyco, and Perl quite in the dust if you ask me (this is
not so surprising as Lua is a much simpler language, albeit somewhat
less friendly).
The reasons why C Python is faster than Ruby are probably deep embedded
in how their source code is coded, but, out of the top of my head:
- C Python relies mainly on reference counting for all its objects by
default, while Ruby uses a pretty inefficient garbage collector.
- C Python uses byte-code compilation, while Ruby (sans YARV) does not.
- C Python does have a couple of constructs that are efficiently
optimized by the interpreter (list comprehensions, for example). The
equivalent Ruby block code is usually not optimized at all.

> 2) Why are many mainstream organizations using Python rather than ruby?
> Is it simply an age issue (Python has been around longer)? Is it a
> performance issue? Is this changing currently?


Age, performance, origins of Ruby, and lack of knowledge about it till
about 3-4 years ago.
I'd say Ruby really became "mature" as a language with v1.8 (only about
4 years ago) and truly popular with Ruby on Rails (RoR), just two years
ago.

>
> 3) how did they gain this foothold? Why not ruby for standard
> Linux config scripts?
>


Probably for the same reasons as 2).

> Thanks so much for any answers you all have. I can only hope that ruby
> will begin to rival Python in the "mainstream" (whatever this means).
>


Ruby is already quite mainstream, and in a domain that matters quite a
lot, which is the web. Thanks to RoR, most new websites now built are
likely to be built around Ruby than other technologies. Albeit python
did get (and probably still is) used in some places around the web, for
the most part python has struggled to achieve the massive user base on
the web that, say, Perl, PHP, Java or Ruby have obtained at some point
of their lives.
Ruby's popularity is still clearly on the upswing, unlike python which
seems more or less stuck, if you are to believe some of the statistics
published for 2006 (O'Reilley books, TIOBE index, etc).


Gavin Sinclair 01-19-2007 03:52 AM

Re: Ruby and Python, questions (not a flamewar!)
 
On Jan 19, 6:03 am, "Giles Bowkett" <gil...@gmail.com> wrote, in part:

> Basically, the advantage is the bytecode interpreter, and that Ruby
> came from outside the West. Faster performance plus lower barriers to
> adoption equals more users.
>
> (Or at least, more users for now. Ruby books are outselling Python
> books today, according to O'Reilly.)


Citation needed :)

The information I've seen on this suggested that Ruby book sales were
_growing_ at a faster rate than Python book sales. That's not at all
the same thing as saying that Ruby books are outselling Python books.

Of course, perhaps I haven't seen the most up-to-date information.

Gavin



All times are GMT. The time now is 08:28 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.