Thursday, September 21, 2006

Ruby and Python - there's no fight

Apparently, it's a fight to the death between the two languages, based on the ecological principle of "competitive exclusion" which states that two species can't share the same ecological niche without specialization or one becoming extinct.

I have problems with this analogy because it doesn't account for the evidence, and I also have issues with the above gentleman's assertions that Ruby is more powerful.

Remember when everyone stopped using PHP?

Hah, I wish. But here's a list of languages/frameworks that share the same ecological niche in the coding world, but yet are still present and still being used.

  • ASP/ASP.NET/PHP/your templating language here
  • Javascript/VBScript
  • Java/C#
  • VB.NET/VB6
  • Ruby/Python/Perl
  • Haskell/OCAML
I'm sure there's thousands of other examples that I've missed. If the principle of competitive exclusion applied in the programming world, there'd be one templating framework, one client-side browser scripting language, one functional language, etc. etc.

Programming languages are not subject to natural selection

Natural selection is ruthless. Humans, not so. The fact that there are still COBOL programmes running will attest to this. There will always be plenty of room within a "niche" for various alternatives. Aside from dubious, highly unscientific assertions based on book sales via O'Reilly, there's no evidence that Ruby is usurping Python's userbase. (Re: those book sales - Ruby's community should take that as a sign that they need to improve their online documentation.)

Ruby users be hatas, yo... why?

Funnily enough, when I see statements like "It's a fight to the death" it's invariably from a Ruby user.

I don't see it from Python users because Python is out of the One True Language (OTL) phase, so the userbase isn't as fervent these days, we're a bit more tolerant, and more willing to filch good ideas.

I came into Python just as the OTL phase was ending (in those days, it was fight to the death between Perl and Python), so I've seen the community mature over time, and the fanatics either settle down or move on. (Guess where they moved onto...)

So, a question for any Ruby users who read this - you seem to be of the opinion that Ruby needs to kill Python. Why? Python didn't need to kill Perl.


Now, moving onto address Tomasz Węgrzanowski's points. Incidentally, anyone else find his usage of a cat picture highly ironic given the nature of the post? Unintentional, I'm sure.


Power and popularity

Quotes from taw are given in italics. He states that

right now - Ruby is a bit more powerful, Python is a bit more popular

and he defines power and popularity as:
  • Power (expressiveness, performance etc.)
  • Popularity (which results in more libraries, better tools, fewer bugs etc.)
So if you want Python to win:

Reduce the gap in power - make Python support blocks, get rid of explicit self and get better support for metaprogramming. If Python did it a few years ago, nobody would have heard of Ruby. If you don't like blocks, metaprogramming and implicit self, you don't have to use them - simply consider them a price to pay for making Python the next big thing. If it gets them today, it is still very likely to win.

I must admit that I fail to see how the usage of self means Python isn't as "powerful". It fits with the Python philosophy of explicit is better than implicit - I can't see how it impacts performance or expressiveness in any way. Blocks would be nice, but metaprogramming? If metaprogramming is why I need a language, I'm going to use a Lisp dialect.

Reverse gap in power - can Python express certain things a lot better than Ruby ? Write useful programs and libraries that would be much more difficult without this power and popularize them. Attack the enemy where it is strongest.

I don't understand this point, so I can't really answer it.

Make the most of greater popularity - work on useful things that are very useful but hard to reproduce with smaller user base - like Psyco and stable ports to JVM and .NET

Okay. Do Jython and IronPython 1.0 qualify as stable ports to JVM and .NET? IronPython even managed to retain compatibility with most of the CPython standard library.


And if you want Ruby to win:

Increase power advantage - take powerful features from Lisps, Smalltalk, Erlang, Haskell or whatever, and integrate them with Ruby - making different paradigms work together is one of the greatest strengths of Ruby, so make use of it. Make metaprogramming and DSLs easier by writing metalibraries and tutorials.

I'd add a cautionary note to this, there's an old saying about being a jack of all trades, but a master of none. Ruby should focus on being a good Ruby, and not a half-decent Lisp, a quarter decent Erlang and a two-thirds okay Smalltalk.

I'd still reiterate that if you need to metaprogramming and DSLs that you're more than likely going to be using Lisp. L# has just been released, which I find interesting, as it has access to the .NET libraries.

But anyway, before Ruby goes stealing stuff from every other language, give it threading and unicode first. Get the basics right.

Make the most of greater power - Ruby was able to get the momentum with Ruby on Rails, which would be very difficult to replicate in other languages. Ruby makes writing powerful embedded DSLs very easy, and powerful embedded DSLs are a potentially huge and pretty much unfilled niche. Take it and use it as a leverage to get more popularity.

Ruby on Rails is hard to replicate? Sorry, Django, Turbogears, Pylon, Zope, Cherrypy etc. you guys are too hard to use... erm... RoR is easy to replicate.

DSLs are a hard way to sell your language. They haven't worked for Lisp yet. Before you can sell Ruby based on DSLs, you need to tell people why they need DSLs.

Minimize effects of lesser popularity - if Python has a good library for something, simply recode it to Ruby and call it version 1.0. The languages are so similar that you should be able to do it in no time. You can get it more Ruby-like (with blocks etc.) later.
To be honest, I wouldn't recommend this. For example - Ruby's imap library is, in my opinion, better than Python's imaplib (apologies to ESR who wrote the part that annoys me the most, but an IMAP library that requires me to use syntax from the IMAP4rev2 RFC is failing), so replicating some of Python's libraries would be a mistake - at least until Python 3000's general revision, tidy up and improvement of the standard library has occurred.

There are some things in which current implementation of Python is simply better - Ruby 2 is trying to fix many of those (you cannot have Ruby Psyco without YARV). If you can - help with Ruby 2.

Yes. The priorities of the Ruby community should be - threading, unicode, speed, documentation. These are what Ruby needs right now. I'll keep an eye out.

6 comments:

Anonymous said...

i like your mention of
"the One True Language (OTL) phase"
(in a language's life cycle)

nice 'middle way' article!!

.: http://secretGeek.net :.

Justin Rich said...

In a python user's group I used to attend they (and i greatly respect these people's knowledge of software development) referred to Ruby as the R-word. It was like they were offended that Ruby was gaining popularity (and they were largely Java developers in the day!). So while I agree with the middle way, both sides have people who throw stones.

taw said...

Cats are absolutely adorable, but in nature they're ruthless killers. So are Ruby and Python :-)

Cynos said...

Hahah Taws. I still hold that neither language will kill the other, and refer you to Perl's continued existence as proof.

About four years ago, It was Python in Ruby's role and Perl in Puython's. Give it a few more years, and there'll be posts about Blub vs Ruby. ;)

Anonymous said...

Where exactly did you see someone say:

"It's a fight to the death."

And why would you take someone that stupid seriously?

Anonymous said...

That is so great!
It's also possible to run python in parallel on SMP: Parallel Python