IronRuby Emerges

posted @ Monday, July 23, 2007 5:57 PM

 

So John Lam annouced the alpha release of IronRuby, he mentions that they did a lot of work on string and arrays, unfortunately, with the current release .NET types aren't able to execute Ruby mixins. I was hoping to do something like the following:

require 'mscorlib' 
require 'System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'

list = System::Collections::ArrayList.new
list.Add(5)
list.Add(10)
list.Add(15)
list.extend Enumerable
list.each {|i| puts i.to_i}


The following code does execute:

require 'mscorlib'
require 'System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'
require 'System.Drawing, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'
require 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'

Application = System::Windows::Forms::Application
Form = System::Windows::Forms::Form
Button = System::Windows::Forms::Button
Point = System::Drawing::Point
Size = System::Drawing::Size
MessageBox = System::Windows::Forms::MessageBox
window = Form.new window.text = 'Testing IronRuby'
window.size = Size.new(250, 200)
button = Button.new
button.text = 'Click Me'
button.location = Point.new(75, 75)
button.click {|sender, e| MessageBox.show 'I was clicked'}
window.controls.add(button)
Application.EnableVisualStyles
Application.run(window)

Of all the windowing toolkits I've seen for Ruby, the .NET Framework is the easiest to read for me, although I'm sure toolkits like Swiby will get noticed, especially due to it's DSL syntax which is the new hotness in the development world these days. Next up, extending the IronRuby Builtins.