Ian Bicking: the old part of his blog

Re: Ruby, Python, "Power"

Nice article! One very important thing I miss in your article, however, is a comparison of documentation. Good language and library documentation is as much a part of a language as its most common interpreter or its standard library itself, which you do address. Finding your way in a language may actually depend a lot more on the actual docs available than on any "principle of least surprise" or whatever. Only after using both Python and Ruby for various projects, I realised how important this is - coming partly from a PHP background. No matter how ugly PHP as a language might be, its documentation, both in terms of quality of content as ease of use/accessibility, is way ahead of both Ruby's and Python's.

I personally find the python documentation extensive, but very very messy. A list of dict methods is here, things about how lists work is there, and please look underneath the table for string methods, thank you. Oh and if you look in a totally different place, you'll find that there are also global functions operating on strings, with the same names. Naturally, we did not make a link between these two places. To my experience, Ruby performs better here, having a very decent, but maybe a bit concise, reference for built-in classes and modules that is up to date. Its standard library is, i believe, documented even worse than Python's, though (but at least a bit more functionality is considered built-in).

Comment on Ruby, Python, "Power"
by Egbert Teeselink


One big difference is overriding or extending built-in type objects. You mentioned the case of an operator, but like you said, that isn't a big deal. But how about overriding existing, or adding new, str methods? You can't tell me that isn't useful!

In Ruby:

class String
  def validate()
    if (self.include?(' '))
      return false
    return true

puts('This should have no spaces'.validate())
>> false

In Python (just a PoC):

def validate():
  if (' ' in self):
    return False
  return True
str.validate = validate

print('This should have no spaces'.validate())
>> TypeError: can't set attributes of built-in/extension type 'str'

Don't get me wrong - I like Python. I use it alot (in fact, these days, more often than Ruby). I just wish it let me setattr on built-in objects.

# MonkeeSage

Well. Writing documentation for PHP is simpler that for Python or Ruby as PHP is only a collection of functions in a single namespace. Not talking down to PHP in any way with that. But it's limited structure is quite simple to document.

# Jon Gretar