Ruby 1.8.0 Released
waieitch writes "A long-waited new version of the scripting language, Ruby 1.8.0 has just been released. You can download from here, and the changelog is available. With many new libraries, say dRuby, ERB, REXML, this version is doubled by 1.6.8 in size."
> * Blocks are litteraly a bag hung on the side. Needlessly ugly and limiting.
Why do you feel they are ugly? Ok, they are not real functions like scheme has them, but Ruby wants to be an object oriented language, so it's ok that they are (can be transformed to) objects.
I don't object to blocks being objects; I object to them being arbitrarily forced into a special-syntax-optional-singleton-parameter gheto. Why can't I define a method that takes two or more blocks (e.g. if/then/else) with the same syntax I use for methods that take a single block? Why can't I introspect the structure of a block? Why the duality with Proc objects? In short, why aren't blocks first class objects?
>* The typographic hungarian notation ($ for globals, capitals for constants, etc)
Hungarian notation encodes the type of a variable into the variable name. In Ruby the sigils are used to show the scope of the variables.
Hungarian notation (as the term is generaly used) encodes metadata into the variable name. Type, class, scope, storage class, etc. are all metadata. None of them should be duct-taped on to variable names (IMHO) because it obscures the intent of the code with a clutter of details about the means.
You can see at one glance that @@foo is class variable, @bar is an instance variable and $baz is a global variable. I found this to be very useful while refactoring code.
Sure, and I can imagine cases where it would be handy to have a language require that every variable reference includes a comma seperated list of the line numbers of each reaching assignment. It sure would make it easy to spot uninitialized variables, for example. But in general, it would make the code harder to read and maintain.
More to the point, in ruby I'd like to be able to change the scope or storage class of an object reference without having to rename it.
-- MarkusQ
AFAIK, Python doesn't let you subclass built-in types, and it certainly doesn't let you treat integers as objects.
>>> class IntegerSubclass(int):
... pass
>>> issubclass(IntegerSubclass, int)
1
In summary though, I don't know Python or Ruby well enough to enumerate all the differences between them. I just find that nearly every program I want to write becomes much shorter and easier in Ruby than it was in Python.
Doesn't sound like you've really spent enough time in Python to make that comparison.
"First you gotta do the truffle shuffle."