Jeremy McAnally

Improvements to Ruby

Pat Eyler has another blogging contest up, and fortunately it's a topic that I've been thinking a lot about lately.

The Rubysphere, especially Rails, has hit two barriers with would-be adopters: knowledge transference (addressed here) and language features. Two of the language features that seem to really put people are dynamic typing and lack of Unicode. The first, of course, to those who use it, is an extreme advantage. Having done development with statically typed languages for some time, I can tell you that I praise God for the day that Yukihiro Matsumoto released Ruby. Dynamic typing (with Ruby or Python or otherwise) is a dream compared to the nightmare that is static typing. BUT there are those who would prefer to keep that "safety net" (if you want to call it that) of static typing around. I've thought of a couple of non-intrusive ways for those people to be satisfied while also appeasing those who are hardcore dynamic typers. First, optionally type specified parameters. For example, rather than simply:

def my_method(param, param_two)
  puts "Well, hello!"
end

You would have something like...

def my_method(Integer param, MyClass param_two)
  puts "Well, hello!"
end

If the types didn't match, then an error would be thrown. This would not only appease static type junkies, but it would also cure the plague of blocks like this:

def my_method(param)
  do_something if param.is_a?(String)
end

Another possible solution is optional exclusive assignment. For example, let's say you had something like the following...

my_value = 13
my_value = "Now a string!"

But you didn't want my_value to be able to be coerced into a string; you could optionally do something like this:

Integer my_value = 13
my_value = "Now a string!"   # => Error!

This would give those who desire it a safety net until they can really get into static typing and testing for type. I think this would attract a lot more talent from the Java and C++ worlds than we have right now, which really can't hurt anyone if we can get them speaking Ruby Proper. :)

The other features that is lacking is internationalization. I'm aware of the options, but none of them really suffice when compared with those available for Java and C++. If we want to really see Ruby taking off in this globalized culture, we're going to have to invest some time into internationalization, even possibly integrating it into the core of the language automatically (a la Python). Python has this:

u"I'm unicode!"

...to create unicode strings. I can't say I hate it, because it's nice, easy, and more convenient than some of the convoluted solutions I've seen.

These changes are mostly just things swirling around in my head, but it would be really cool to see them materialize somehow, either through a gem or a language improvement.