John Lam 1997 — 2026

Building bridges

I’ve been building a bridge from Ruby to the CLR in my spare time. It’s a complicated piece of software, and I plan on explaining how I created it in a series of posts on this blog. At the time of this writing, I can consume CLR objects from Ruby scripts and implement event handlers in Ruby scripts. The Ruby language can make it possible for people to create applications that would be more difficult and take more time using C# or VB.NET. The Ruby language has certainly changed the way I think while writing code; I hope to bring that power to people writing .NET code today. Here’s a teaser:

require   'RubyShim'
reference 'System.Windows.Forms'

include System::Drawing
include System::Windows::Forms

f               = Form.new
f.Text          = 'My Form'
f.AllowDrop     = true
f.SuspendLayout

label1          = Label.new
label1.Location = Point.new(40, 32)
label1.Width    = 200
label1.Text     = 'My Label'

button1          = Button.new
button1.Name     = "MyButton"
button1.Location = Point.new(40, 57)
button1.Text     = 'Click me'

button1.Click do |sender, args|
  p = sender.Location
  label1.Text = "clicked on #{sender.Name} at #{p.X}, #{p.Y}"
end

f.Controls.Add(label1)
f.Controls.Add(button1)
f.ResumeLayout

Application.Run(f)

This will be an open-source project, and will be redistributed under an MIT-style license. I have not yet released the source code since it is largely proof-of-concept code at this time. If anyone really wants to take a look at it right now, just send me an email and I’l be more than happy to share.

I believe that I have solved most of the hard problems. I have Windows Forms and Avalon applications written in Ruby and running on my computer today.