Anything that may convince me that Python can stop the Ruby on Rails? What are the advantages to kill the python with a stick and board the ruby express?
I dont know much about Ruby and long time I dont use Python. My feeling is that Python has been used for longer in the web, so it might be superior for many applications. But, my guess is that Ruby might be superior for some task related with data analysis. So, at the end is about what is the kind of applications that you are planning to develop or deploy and other considerations such as current infrastructure you have, the resources you have for the development and current expertise in your team.
During the last year I spent quite some time using both. All in all they are mostly equivalent, they are powerful dynamic strongly-typed languages with decent support for a bunch of programming paradigms. So just's take a look at the differences:
- Ruby is more fun to write, the syntax is very flexible and you can hack the language in so many ways... you can monkeypatch (i.e., change an existing class) even the basic types. Yes, you can add method to or override the String class if you want to. It is possible to shape your own internal-DSL (see Fowler's book on DSLs) and blocks are a lot more fun to write that lambda or list-comprehension in Python.
On the other end Python is a lot easier to read. Take a python project you did not write or one you wrote some months ago, chances are high that you are going to understand it.
- Ruby has a fantastic integration with Java through JRuby. So you can write application Ruby reusing all the Java libraries and taking benefit from the speed of the JVM. Great. I advice to look into the libraries which are available for your main area of interest, that can do a huge difference.
- With both you can use C extensions. Writing them for Ruby is just a lot easier IMHO.
So said there are more similariies than differences, event some of the major frameworks are resembling: the good ideas which appear in one ecosystem get replicated in the other.
You can read docs on the command line (with the ri command instead of pydoc).
There are no special line terminators (except the usual newline).
String literals can span multiple lines like Python’s triple-quoted strings.
Brackets are for lists, and braces are for dicts (which, in Ruby, are called “hashes”).
Arrays work the same (adding them makes one long array, but composing them like this a3 = [ a1, a2 ] gives you an array of arrays).
Objects are strongly and dynamically typed.
Everything is an object, and variables are just references to objects.
Although the keywords are a bit different, exceptions work about the same.
You’ve got embedded doc tools (Ruby’s is called rdoc).
Differences
Unlike Python, in Ruby,…
Strings are mutable.
You can make constants (variables whose value you don’t intend to change).
There are some enforced case-conventions (ex. class names start with a capital letter, variables start with a lowercase letter).
There’s only one kind of list container (an Array), and it’s mutable.
Double-quoted strings allow escape sequences (like \t) and a special “expression substitution” syntax (which allows you to insert the results of Ruby expressions directly into other strings without having to "add " + "strings " + "together"). Single-quoted strings are like Python’s r"raw strings".
There are no “new style” and “old style” classes. Just one kind. (Python 3+ doesn’t have this issue, but it isn’t fully backward compatible with Python 2.)
You never directly access attributes. With Ruby, it’s all method calls.
Parentheses for method calls are usually optional.
There’s public, private, and protected to enforce access, instead of Python’s _voluntary_ underscore __convention__.
“mixins” are used instead of multiple inheritance.
You can add or modify the methods of built-in classes. Both languages let you open up and modify classes at any point, but Python prevents modification of built-ins — Ruby does not.
You’ve got true and false instead of True and False (and nil instead of None).
When tested for truth, only false and nil evaluate to a false value. Everything else is true (including 0, 0.0, "", and []).
It’s elsif instead of elif.
It’s require instead of import. Otherwise though, usage is the same.
The usual-style comments on the line(s) above things (instead of docstrings below them) are used for generating docs.
There are a number of shortcuts that, although give you more to remember, you quickly learn. They tend to make Ruby fun and very productive.
There’s no way to unset a variable once set (like Python’s del statement). You can reset a variable to nil, allowing the old contents to be garbage collected, but the variable will remain in the symbol table as long as it is in scope
Each language has its own advantages and drawbacks. It is not easy to say which is better or worse. There is a very simple advice - choose a tool based on the task, and which will help complete the task best.
There can be found a comprehensive list of features that are missing or available in each language: http://stackoverflow.com/questions/1113611/what-does-ruby-have-that-python-doesnt-and-vice-versa
In my opinion, the Python syntax is more readable to the beginners. As I know, Python is very popular in academy as it is equipped with powerfull libraries that fit scientific computing - Numpy, Scipy, BioPython, etc. As the libraries are usually implemented in C/C++, they are very fast.
It depend on your use. For web development, Ruby on Rail is better than django (Python). But, for scientific calculation, Python is better than Ruby. Because, Python has a lot of package (like numpy, scipy, pandas..) for scientific calculation.