On Tue, Jan 20, 2004 at 10:58:21PM +0200, Ville Vainio wrote:
> Though "sending messages" to int literals is a syntax error.

> 
>     Phil> 10.times do something end
> 
>     Phil> is somehow so clear.  It's almost zenlike.
> 
> It's cute and fun to write

It's not "cute", it's legible.  "10.times do" is *much* clearer
about what's going on than, for instance, C's "for (i=0;i<10;++i)".
The Python idiom is probably something with a Range, which is clearer
than the C, but not as clear as the Ruby.

> I kinda like Python's "\n".join(["foo","bar"]), even if most
> seem to consider it a wart for readability reasons.

Well, I think it's a kludge, designed that way only because strings have
recently grown a base class to which methods could be added,
whereas sequences have no such basis, so there's nowhere to define
something clearer like ["foo","bar"].join("\n").  

And the lack of such a basis is part of my whole problem with
Python, the lack of true object-orientedness.  The ability you cite
to treat primitive types as objects is a fairly recent development;
the above was originally done by importing 'string' and calling
'string.join("\n", ["foo", "bar"])' (I believe that was the correct argument
order).  The object-orientedness just doesn't cut deep enough. I mean,
it's not as much of an afterthought as it is in Perl, but 
holdovers from the procedural design poke through everywhere.  
Things like "len" and "dir", which should logically be methods, are
instead global functions.  And why "len" instead of "length" in
a language vaunted for its readability?  Or "dir" - the filesystem
analogy makes a certain amount of sense, but there must have been a more
transparent name for it.

I somewhat like, from an elegance perspective, the idea - shared by Python and
JavaScript - that functions and methods are just variables whose value is a
Proc (in Ruby terms), and trailing parentheses are an "invoke" operator.  
But I don't like the resulting merger of namespaces - if an object has
a method named 'foo', it can't have a member variable named 'foo', etc.
I also don't like that object members are public by default.

Also, the one time I tried mixing Python and C, it was not terribly 
easy to do.  Again, we're not talking XS here, but Ruby's design lets
you write Ruby in C just as if it were Ruby.  I love that.

-Mark