tags:

views:

744

answers:

11

G'day folks. I'm trying to introduce Ruby at work, and a few people are interested. However, I've been asked to present the benefits of Ruby over Python and PHP.

I've broken this down into 2 parts: 1) show Python and Ruby's advantages over PHP; 2) show Ruby's advantages over Python.

The first is easy. I'll explain things like:

  • Everything's an object.
  • Python and Ruby are easier to read and write.

For the second, I'm thinking of:

  • Ruby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now
  • RSpec is miles ahead of Python's TDD and BDD frameworks.
  • GitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.

Do you have any suggestions? I'm all ears!

+12  A: 

Hmm, as an active programmer in all three languages I simply can't agree with the sentiment that either is better than the other. Sure, Python and Ruby are more object-oriented, but that's not a requirement to be better, it's only a convenience. You can't beat the community of PHP and the legacy (for good and for bad) of code, nor ignore the direction PHP is taking for the future, the mass of support, the distributed servers ready for it, and so on.

If you want to focus on syntax, then all three have their strong and weak points. If you want to talk about back-end technology, then as all three are moving active open-source projects, there really is no winner.

Except, you, the programmer, who can mix and choose what best suits you. Remember that even if you think Ruby is the best thing since NAND gates it doesn't mean others follow. And remember also that we're all different; some people actually like Java and .Net, just like others love LISP. We're all different, and I doubt any of the Ruby/Python/PHP contenders are any better than the other. Sorry.

AlexanderJohannesen
What's the weak point in Python's syntax?
S.Lott
I don't consider this a weakness but for a language that claims beautiful is better than ugly: the . and __ syntax can be confusing.for example: super(Car, self).__init__("Mercedes")I think its hideous somehow. IMHO
MrHus
+28  A: 

If your goal is to show why language X is better than language Y, you're stuck in subjective-land where there are no right answers.

No, Ruby is not better than PHP or Python. It might be more suited for a given purpose, and for that you can give specific examples. PHP is a poor choice for writing an SMTP server; Ruby and Python will serve you better (in fact, in Python it can be done in just a few lines, can't speak for Ruby though). On the other hand, PHP is better suited than Ruby for writing a one-off, short backend for an email submission form. The code is short, easy to maintain, quick to write, etc.

PHP has an absolutely huge developer base, making programmers easy to find, which comes in handy if you ever want to out-source any aspect of the development chain. On the other hand, it's also terrifically easy to write horrible code in PHP, and there is more than enough of that going around.

Python has a much larger user base than Ruby, and indeed is the primary language that RedHat uses for developing system tools. So if you're on a RedHat derived server (and statistically, chances are pretty good that you are if you're using Linux) then Python is guaranteed to be already in-place and working properly, etc.

In short, weigh the benefits, make a decision, but don't assume that people will agree with you; after all it's just an opinion.


Edit

It just occurred to me that I failed to state the whole point: you shouldn't be trying to convince other people that they should use Ruby over Python/PHP. Instead you should be trying to determine whether you should use Ruby over Python/PHP.

You can't go fact-finding like this having already determined what the answer will be -- that's not helpful. Instead you should be gathering information on the benefits and drawbacks of each language and weighing that against the requirements of your company. Once you come to a conclusion, you'll already have a preponderance of evidence showing it was the correct one.

tylerl
+1: Choose a language based on your requirements. Don't justify your favorite language.
S.Lott
A: 

All 3 languages have their place. As with any programming task you must pick the language best suited for the task. Python has list comprehensions, php is much better when embedding and generating html. Ruby is a great language too. One of the things I have found myself using in ruby a few times is the 'a'...'zzzzz' to generate all possible strings of size 1 - 5. They all have their advantages and are all better than the others at particular tasks.

Matt
I would argue that embedding html in php is not so much an advantage as a bad habit that it will let you get away with. There are times when it's a handy shortcut, but too often it's abused (I know I have!) when templates would be a better option..
Jon Cage
+12  A: 

Don't get sucked into comparative arguments - unless you're experienced in all three languages, you'll just be revealing your ignorance - especially when claiming "X can't do Y". The true fans will take you down.

Instead, show off what ruby can do. It's a great language, but that has nothing to do with how well people talk about it. What matters is the code. So show off. Demonstrate your productivity, reliability, and flexibility with the language. Make it the easiest thing to follow at the code review. Have suites and suites of tests. Read up on sneaky techniques from RedHanded if you have to. Win your coworkers with your code -- it'll be far more convincing than your words ever could be.

rampion
A: 

If you are inclined towards a language or a software then you will tend to see only the goodies compared to others. If you want to do real comparison then comapre pros and cons and see if Ruby is clear winner in terms of what you want to achieve with that language in your company. If you do this and your company see benefits of Ruby then surely they will use.

Bhushan
When all you've got is a hammer, everything looks like a nail :-)
Jon Cage
+3  A: 

Devil's advocate maybe...

  • Everything's an object.

This is a feature of Ruby, but it is not self-explanatory as to why this is a benefit. You would need to pre-prepare an argument for why that is a benefit. When convincing somebody of something's superiority, always think in terms of showing the benefits, not the features.

  • Python and Ruby are easier to read and write.

This is a very big claim to make, and I would not be comfortable making such a claim without a substantial amount of credible objective third party evidence supporting this. If not, and I suspect such a claim really couldn't be backed up, I would play it safe and avoid making such a claim. Making a claim this substantial, but only backing it up with personal opinion or anecdotal evidence would not be a good idea.

  • Ruby has many conveniences, which makes it easier to read and write. Eg: Optional brackets, and being able to open built-ins, allows for things like 2.days.from_now

Again, you will need to think benefits, not features. It may be true that it has optional brackets, but you cannot just mention a feature, you have to explain its benefit - why that feature is a better idea than any other approach. Personally I am not sure that 'optional' syntax is ever a good idea, and would need a fair bit of evidence to convince me that it was.

  • GitHub and RubyForge are fantastic resources for finding, releasing, and collaborating on software.

That's good. There are also similar resources for languages other than Ruby - again, you will need to not only mention the existence of these but explain how they are better than the alternatives.

Good luck.

thomasrutter
Agree that optional syntax is not a good idea.
mikelikespie
A: 
Happy programmers == productive programmers
Ruby              == Happy Programmers

So that must mean

Ruby == productive programmer

Convince them both these statements are true and you are there. Assuming of course Ruby makes you a happy programmer.

Squeegy
What about the other languages? The OP wanted to prove Ruby was _better_ than the others, not just good..
Jon Cage
My point was that when things are more or less equal, use the one that makes your programmers happy because it will lead to better and more productive. If that's ruby, great.
Squeegy
+5  A: 

If you really want to show Ruby is better (assuming it is for your application!), why not try writing a small app from scratch in front of them? It doesn't have to be big, but something relavent to what you'll eventually be using it for is a good idea.

Write the app in all three languages including any configuration for the server (I'm assuming you're writing a web app here using DJango / Rails / PHP right?) and show how much faster you are, how much cleaner the code is etc. ...assuming it is ;-)

You can finish up by asking them what they'd like to add to it and then try adding that feature if it's a small change. Nothing like a bit of audience participation - people like applauding themselves. If you get them involved they're more likely to accept the winner.

For the record, I've tried all three and would agree that both Ruby and Python seem to result in cleaner code. I'd go for Python over Ruby though - there was something clunky about the syntax of Ruby when I tried it that I just didn't experience with Python.

Jon Cage
+1: Code Demo is about the only reasonable approach. What you find is that n00bz have trouble reading Ruby -- which is very important. It's hard to read when compared with Python or PHP
S.Lott
That was certainly my experience. I tried learning Ruby+Rails for a bit before I discovered Python+Django and whilst I could see it was powerful I kept tripping up trying to understand the snippets I found. My experience with Python+Django has been much more productive :-)
Jon Cage
+2  A: 

You're going to have a tough sell over python. GitHub is written in Ruby, not for ruby per se, by the way.

For python one has BitBucket (even though I do prefer git), as well as pypi.

Correct me if I'm wrong, but it sounds like you haven't looked at python code all that much. (I've written buckets of both python and Ruby by the way) I find it much more readable, especially when you're working on code that's not your own.

Anyways, not really answering your question, and don't really want to contribute more to the flame war.

mikelikespie
+1  A: 

Actually no one ever conviced me (at least directly), to use one programming language or another.

I used to have a certain need for clearness (if you might call it that way) and some other criteria, a language and its ecosystem should meet. And you definitively will end up using some stdlib, and third-party resources, so you might want to look into them as well (and use them as arguments).

I am a fan of both, ruby and python (and these languages conviced me both by their design, their constant progress and their communities). The general notion of a scripting language makes them equally appealing. I found gem to be one of the slowest software I ever used. And personally, I think pythons stdlib is better organized than rubys. But I like Ruby Mixins, they are elegant and safe a lot of time.

In short: You could point your colleagues interest to some current hot spots, where coding is just hard, then show some alternatives in ruby. Rake is a great tool as well, demonstrate it ... Just be rationally passionate about it .. The rest will come ..

The MYYN
A: 

This kind of post gives Ruby programmers a bad name. Ruby is Beethoven, Python is Bach. If you prefer one style to the other, fine, but don't try to argue the superiority of one over the other.

banister