Chris Umbel

ironruby

for the last year i've somehow been avoiding doing any ruby work. been writing plenty of python for prototyping as and duct tape for work as well as hobby, but nothing in the way of ruby.

one of the reasons i've had the opportunity to write some python is because of ironpython. no matter how much diversity i would like in my professional development the truth is i work in a microsoft shop. it's just that simple. because ironpython lives in the .net runtime i only have to be slightly creative to get some professional use out of it.

with the advent of .net 3.5 microsoft (thanks in part to john lam) has introduced ironruby. much like ironpython the idea is simple. marry the .net runtime with the ruby programming language and its dynamic nature.

here's a simple example of creating a simple wpf interface in ironruby:

# load wpf
require 'PresentationFramework, Version=3.0.0.0, Culture=neutral, 
  PublicKeyToken=31bf3856ad364e35'
require 'PresentationCore, Version=3.0.0.0, 
  Culture=neutral, PublicKeyToken=31bf3856ad364e35'

# make a window
wnd = System::Windows::Window.new()
# make a button
btn = System::Windows::Controls::Button.new()
btn.Content = "Click me"

# assign a ruby block to a buttons click event
btn.click do |sender, evt_args|
	System::Windows::MessageBox.Show("Hello from WPF in ruby.")
end

# slap the button on the window
wnd.Content = btn

# start the application
app = System::Windows::Application.new()
app.run wnd

Fri Apr 11 2008 00:04:00 GMT+0000 (UTC)

Follow Chris
RSS Feed
Twitter
Facebook
CodePlex
github
LinkedIn
Google