Ruby vs Python

  • Whitespace matters. Having to "end" everything in Ruby really sucks, especially since my code is always correctly aligned.
  • No ternary if. Seriously, I have to type this kind of crap in Ruby all the time:
    v = a.empty? ? a.shift : nil
    In Python this would be:
    if len(a) > 0:
                v = a[0]
                a = a[1:]
        else:
                v = None
    This is clearly less error-prone and more readable than Ruby's.
  • Better built-in methods. For example, you can simply do sum([1,2,3]) in Python, whereas you would have to do [1,2,3].inject(0) { |sum, i| sum += i } in Ruby. Seriously????? Why is it called inject anyways. Ruby's authors were clearly not well at English.
  • Faster. Because Python is so much simpler than Ruby, its VM is almost an order of magnitude faster to make up.
  • More production ready. I read somewhere that Google is using Python.
  • Better commenting. In Python you can do:
    def getTime():
            '''Returns a string timestamp in the form: 'Time hh:mm:ss' '''
                ...
    but in Ruby you're stuck with
    def get_time
            =begin doc
                Returns a string timestamp in the form: 'Time hh:mm:ss'
            =end
            ...
  • http://www.rossbeazley.co.uk/pablo-lorenzzoni-ruby-versus-python/open-source/

    Filed under  //  Python   Ruby  
    Comments (0)
    Posted