On 31 Jul 2009, at 17:55 , Steven D'Aprano wrote:
But seriously, while I admit that I have very little Ruby experience, and so aren't in a great position to judge, it seems to me that Ruby doesn't have anything like Python's over-riding design principles (the Zen). If
there is a design principle to Ruby, I can't see what it is.

As far as I know, Ruby doesn't have anything like the Zen no. But then again, I don't know any language other than Python with such a document.

Ruby just seems to be far more complicated than Python: things which
Python does at runtime, with a function call, Ruby has special syntax for:

"a bunch of words".split()
%w(a bunch of words)

ord('a')
?a

That's the Perl heritage. And since it inherits from Perl, TIMTOWTDI:
    >> "a bunch of words".split
    => ["a", "bunch", "of", "words"]
    >> "a"[0]
    => 97
(yes, the indexing operator returns a character code if provided a single index. With two, it returns as string slice)

Oh and %w() isn't really equivalent to split(): you don't use it to split a string but to create a list of strings, so the equivalent expression in Python would be `["a", "bunch", "of", "words"]`.

That makes the barrier to entry far higher: it's easier to leverage
existing knowledge to interpret unfamiliar Python code than unfamiliar
Ruby code. Or so it seems to me.

That's probable.

Although I'm sure Ruby has its good points. I'm not convinced anonymous
code blocks are one of them though.

Ruby's code blocks come from Smalltalk, where they are an absolute
necessity since message passing (which code blocks are part of) is the
*only* builtin control flow in Smalltalk - so you just *need* this
construction to provide branching and iterations.

Just because Smalltalk had a particular (mis?)feature doesn't mean that
other languages should copy it. I know, I know, Ruby people swear by
anonymous code blocks, and I've read Paul Graham too. But I'm really not
so sure that the benefits of anonymous code blocks are great enough to
overcome the disadvantages of anonymous code blocks.

What are the disadvantages of anonymous functions?

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to