tags:

views:

330

answers:

4

Hi,

I'm thinking about learning ruby and python a little bit, and it occurred to me, for what ruby/python is good for? When to use ruby and when python, or for what ruby/python is not for? :)

What should I do in these languages?

thanks

+6  A: 

They are good for mostly for rapid prototyping, quick development, dynamic programs, web applications and scripts. They're general purpose languages, so you can use them for pretty much everything you want. You'll have smaller development times (compared to, say, Java or C++), but worse performance and less static error-checking.

You can also develop desktop apps on them, but there may be some minor complications on shipping (since you'll usually have to ship the interpreter too).

You shouldn't do critical code or heavy computations on them - if you need these things, make them on a faster language (like C) and make a binding for the code. I believe Python is better for this than Ruby, but I could be wrong. (OTOH, Ruby has a stronger metaprogramming)

fsanches
Eh, binding C to ruby is pretty easy (or, at least, it is to me). Other than that, I agree with you.
rampion
In what way is Ruby stronger at metaprogramming?
Wahnfrieden
You can easily package the interpreter into your application, and distribute it as a binary using some various tools like py2exe and others.
Wahnfrieden
if you have no experience writing C extensions for Ruby do not say "I believe Python is better for this than Ruby". :)
banister
+4  A: 

If you want to know what people actually use them for, check out Python Package Index, RubyForge, and search SourceForge or even StackOverflow.

As shylent says, you can easily get into holy wars about what they should be used for. Both Ruby and Python are popular especially for prototyping, but you can also build production software like Ruby on Rails, Zope, and Mercurial.

What one would not use them for is code that is performance-critical (most isn't) or close to the metal.

Matthew Flaschen
+2  A: 

They are good for everything.

Ruby has an edge for munging textfiles awk/perl style. That's slightly easier in Ruby. For the rest, I think Python has a string edge, and that it TOTALLY subjective. See http://stackoverflow.com/questions/1113611/what-does-ruby-have-that-python-doesnt-and-vice-versa and the follow-up blogpost http://regebro.wordpress.com/2009/07/12/python-vs-ruby/ .

I use Python for every programming related thing I need to do, and will do that until there is a complete shift in programming paradigm that kicks OO development into the stoneage.

Lennart Regebro
+1  A: 

To avoid the holy war and maybe give another perspective I say (without requesting more information of what fun part of programming the question-ere thinks is cool to do):

Learn python first!

If you haven't done any scripting language yet I would recommend python. The core of python is somewhat cleaner than the core of ruby and if you learn the basic core of scripting with python first you will more or less as a bonus learn ruby.

You will (because you use python) write code that looks very clean and has good indentation right from the beginning.

The difficulties about what to learn is what you actually will you try to solve!

If you are looking for a new production language to solve X the answer get more complicated. Is X part of the language core? Was the language in fact invented to solve X?

If the question was: What single programming language should I Master and eventually reach Nirva with? My answer is, I don't have a clue! (CLisp, Scheme48, Erlang or Haskell should probably have been on my final list though)

PS. I know that this isn't the spot on answer to the very simplified question in the post. what can ruby do that python can't or what can python do that ruby can't.

The point is that when you set out to learn something one usually have a hidden agenda so you try to solve your favorite problem in any language again and again.

If your really are out to learn without have an agenda I think that python in it's most basic form is a clean and crisp way and you should be able to use the same style when using ruby.

DISCLAIMER: I prefer ruby in a production (commercial setup) over python. I prefer ruby over python on windows. I prefer ruby over python on the things I do at home. I do that because the things I really like to solve is more fun to solve in ruby than in python. My programming style/habit tends to fit better in ruby.

Jonke