Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

This is my first question on stackoverflow, so please bear with me. I'm trying to stay away from any form of trolling or flame baiting as i have a tremendous respect for both languages.

I'm a python programmer (though not an expert) and i love it. My first language was C++. My line of work (web development) is pushing me towards other languages like php and javascript.

Recently, I've been very excited by Ruby's increasing popularity. However I used to be under the impression that Python and Ruby were so close that there was little point in trying to learn and master both. But I get the sense that I was wrong, hence my question :

I'd like to hear from python programmers who have either switched entirely to ruby or added ruby to their toolset.

What specific benefits did you get from switching (entirely or partially) to Ruby from Python ?

Ideally I'd like to hear from real world experiences.

share|improve this question
2  
I've been told lambda support for functional programming methodologies in Ruby are more flexible. Might be one advantage. –  a.stgeorge Mar 3 '11 at 0:12
1  
You are kind of late to jump on the rails train now, it's hype has been over for years ... –  Jochen Ritzel Mar 3 '11 at 0:30
add comment

migrated from stackoverflow.com Mar 3 '11 at 1:15

This question came from our site for professional and enthusiast programmers.

closed as not constructive by ChrisF Feb 29 '12 at 17:29

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

7 Answers

This is a pretty good detailed comparison:

http://c2.com/cgi/wiki?PythonVsRuby

I think with Ruby you can make more Magic happening behind the scenes while making your code still look very normal. (Like how in Rails a lot of the SQL logic gets auto-magically generated and your code can look just like a simple statement like 'books.find('Moby Dick').price += 20' where at runtime this would connect to a database do a query, update etc.

Python on the other hand is a lot faster. I would at least do some tutorials for both and then specialize on whatever you liked better or is used at your work.

Also have a look at Google's Go (golang). Which is an interesting statically typed/compiled language with many influences from Python and friends.

share|improve this answer
    
+1 for the C2 wiki page link. –  maerics Mar 3 '11 at 1:13
    
Is python faster? I thought there was a lot of work going on to speed up ruby and that it was now faster than python. Haven't seen any recent benchmarks though, if you have any can you link them in? –  monkut Mar 3 '11 at 2:19
3  
"Is X faster than Y?" is a meaningless question when it comes to programming languages. You need to put "when doing Z?" on the end to make it remotely possible to answer. –  ncoghlan Mar 3 '11 at 2:59
add comment

You will learn to think about problems differently. Ruby and Python are comparable in capability and performance but Ruby seems to encourage functional-style programming whereas Python seems to encourage procedural-style.

Consider the task of splitting a string by some token, reversing the items, and joining them with another token. In Ruby you would do something like this:

"a,b,c".split(/,/).reverse.join("-") # => "c-b-a"

In Python you would probably do something like this:

l = "a,b,c".split(",")
l.reverse()
"-".join(l) # => "c-b-a"

Some might argue that one style is better than the other for things such as readability/maintainability, ease of reading or understanding, etc. But either way, you'll think about problems differently and you only stand to gain in general from that.

share|improve this answer
8  
You could do the Python in one line as well, if you wanted. "-".join(reversed("a,b,c".split(","))). I think the Ruby reads better, though. –  kindall Mar 3 '11 at 1:09
    
@kindall: true true, just trying to illustrate what I found to be one of the essential differences between the languages, not start a golf war ;) –  maerics Mar 3 '11 at 1:17
    
It is worth noting that one of the reasons that Python encourages procedural style is that Guido is not a fan of functional programming. –  btilly Mar 3 '11 at 2:18
3  
More accurately, Guido is not a fan of puritanical functional programming. Computers are good at maintaining state, it makes sense to take advantage of that. –  ncoghlan Mar 3 '11 at 2:56
1  
Your two examples are exactly as procedural as each other. The fact that one is on one line doesn't make it functional. kindall's counter-example is significantly more functional. –  Singletoned Apr 21 '11 at 9:06
show 1 more comment

Mostly anything you can do in Ruby you can also do in other programming languages like Python, so to me the importance of Ruby is not in the features of the language itself, but in the culture and way of thinking. There are two big benefits:

  1. Since the Ruby way of doing things is often unique, it opens your mind to new techniques and you end up being better at programming in every language after learning Ruby. (A lot of people come from other languages and are wowed by Ruby, but then realize that there's no reason they couldn't have been programming like that in Python, PHP or whatever). At work I do all .NET stuff and learning Ruby has still been extremely useful.
  2. My experience has been that the Ruby community is more united than in other programming languages. It seems like every ruby programmer in the world is posting their code on github and publishing gems. Since it's so easy to be involved in the open source community there's a lot of activity.
share|improve this answer
    
Well I think the 2nd point holds true in general. Python has built-in packaging and distribution tools, so we're projects and code everywhere, though we're fractured between Bitbucket and GitHub when it comes to project hosting. In any case, if your not going to be an active member of the Ruby or Python community, your going to be missing out on the biggest, most invaluable resource both languages have. –  Filip Dupanović Mar 3 '11 at 11:54
add comment

There is no real advantage. With python you have everything that you could get from ruby/rails - be it a web framework or a set of libraries for web dev. The advantage with python is that you have lots of libraries not directly intended for web: language processing, image processing, xml/html parsing etc...

share|improve this answer
1  
"The advantage with python is that you have lots of libraries not directly intended for web: language processing, image processing, xml/html parsing etc..." This is not unique to python. –  cam Mar 3 '11 at 0:39
2  
You seem to have a misunderstanding that Ruby has something to do with the web... –  Mark Thomas Mar 3 '11 at 1:31
add comment

I think Rails developers like their 'magic' and python/django programming has a different, perhaps more deliberate programming style.

share|improve this answer
add comment

Well the most obvious benefit you will gain is having the ability to learn and use Ruby on Rails. There is such a huge market for this relatively new technology that learning it wouldn't be a bad idea.

Syntax wise, you won't see that much of a different view. They are very similar, with Ruby learning towards a more functional approach. So that would be another benefit, that when you want to switch to a functional language, it won't seem that alien to you. Paradigm-wise.

I say go for it! Buy the Pickaxe book and get coding. I recommend using a Linux distro as your dev environment. Refer to my question http://stackoverflow.com/questions/5009657/ruby-should-i-learn-it-on-windows-7-or-linux.

share|improve this answer
add comment

It will only take you about eight hours to get pretty far into Agile Web Development with Rails, so why not just try Ruby and see? I prefer Ruby to Python, but I learned Ruby first.

share|improve this answer
add comment