Ruby In Steel’s Optional Type Assertions

In order to provide Intellisense for Ruby, a language that does not have explicit typing, Ruby In Steel turns to type inference. The built-in inferencing can be aided by adding type assertions to a function, for instance:

#:return: => nil
#:arg: c => String
def Bar(c)
@field = c
   puts @field
end

The type assertion block can be automatically added by typing “##” in the line above the function/method declaration (it fills in the type with “Object” to start). I’m a proponent of explicit typing in non-trivial projects so this is potentially a big deal to me. What I need, though (consider this a feature request, SapphireSteel) is some form of FxCop-like reporting / enforcement of type assertion “coverage.”

That is, I would like to enforce a business rule “Ruby programs longer than 500 lines must have type assertions on all functions.” To me, this would be a win-win: you can develop as fast-and-loose as you want, but if you want to check code into a team project, you have to add type information (which, in my mind, is extremely important to the dominant task of understanding code).

To be sure, in my experience the “DocComments” facility in VS/C# (typing “///” triggers a documentation block for the parameters) is widely ignored and FxCop enforcement is resented, but I think documenting parameters in a strongly typed language often seems gratuitous (“string firstName: a string representing the first name” and so forth), while I think everyone admits that type information is helpful for comprehension.

First Look: Ruby In Steel

Here’s the Ruby In Steel editing / debugging experience. Intellisense works dynamically — as soon as you define a function, it becomes available to Intellisense. The debugging experience seems to be the standard VS one (that is, pretty darned good).

REPL functionality is provided by IRB in a console window: not ideal, but convenient. There’s quick access to Rails, Rake, and Gems (see the second screenshot).

The install silently guessed wrong on my Ruby install location, which caused my very, very first “puts 2+2” to fail, but it was easy enough to guess that the issue could be fixed under Tools | Options…

So far, so good: more to come as experiences develop. I look forward to putting this head-to-head against Komodo.