Monday, June 30, 2008

Too Complex?

There's a lot of features of Ruby that I like, but there are some that just drive me nuts like blocks not taking blocks and the ampersand operator. Raganwald did a great job of explaining blocks, procs, and the ampersand in this blog post: Explanation of Ruby's Unary operator. I came away with the feeling, "Wow! It took that much explanation just to tell how to send blocks around?" If blocks were first-class citizens, Ruby would be more elegant. Raganwald would not be writing huge blog posts on block vs. proc because it would be unneeded.

Ruby has all it needs right now. Ruby 2.0 should be a pruning of features and removing special cases. Get to the things that help you concentrate on your design and not on the language. Ampersand is nothing more than noise in your code and brain. Remember elegant is simple.

4 comments:

Jeremy said...

I like the phrasing in the Scheme Standard:

Programming languages should be designed not by piling feature on top of feature, but by removing the weaknesses and restrictions that make additional features appear necessary.

Sadly, R6RS seems to have lost sight of this to a degree.

Reginald Braithwaite said...

In all fairness, although there’s a lot of explanation for how to do unusual things, the simple things really are simple to accomplish, like using blocks with methods.

So although I like the Scheme quote, someone defending Ruby might quote Alan Kay:

Simple things should be simple, complex things should be possible.

:-)

Blaine Buxton said...

I agree that most things in Ruby are simple. It's just frustrating for me when I'm trying to solve a problem and my head is completely into it and then WHAM! I'm caught off guard with a compiler issue or prevented by something else. It's the cognitive friction that I would like to remove from Ruby. I think the core ingredients are there, but I think Ruby should go through a feature removal. The first things for me to go would the ampersand followed closely by all of the built-in global variables.

I would like to see Ruby go the path less traveled and not the one Java took.

Reginald Braithwaite said...

You have my sympathy.