IronRuby Pre-Alpha and Visual Studio 2008 Beta 2
1 comments
Seems as the past days have been release crazy at Microsoft. Many were covering the new Visual Studio 2008 Beta 2 with its more complete and working Cider editor, JavaScript debugging, XBAPs in FireFox 2, nested master pages in the web designer, and much more – recommended reading here. But what caught my attention was the IronRuby Pre-Alpha release.
Let me start off with a teaser: 
So what we can see here is:
I have the ‘rbx’ executable (built using the .NET Fw) that acts like Ruby’s ‘irb’. Once fired up you can go around and fiddle with Ruby code just as you would from the ‘irb’. I know this isn’t big on its own, but looking closer, how is this achieved? And how is this better than ruby-lang.org/en 1.8.6 release? And where could I use ‘rbx’?
Taking things at a time, why is it called ‘rbx’ and why didn’t Microsoft go with ‘irb’? One of the most logical explanations is that most people will be likely to have both implementations of Ruby on their system, and would end up having a naming conflict. Alas, ‘rbx’ is not the final name – and we might expect to see changes in this according to ScottGu. Simple solutions would include renaming J or going around and making your own compile-ruby comandlet or alias in PSH.
IronRuby is built on top the Microsoft’s new DLR – Dynamic Language Runtime, which in turn takes advantage of the whole CLR. This means that one can get the whole flexibility of a dynamic language, including simplicity in syntax and ease of development, while not losing the power of the .NET Framework. On top of the DLR a couple of languages are provided now, some of which we could have tested until now – like IronPython or JavaScript (see the DLR demo from Silverlight). During the MIX07 Silverlight demo, we were able to glimpse a lot of code in IronRuby, but – to our disappointment when you started playing with the DLR Console from the Silverlight Samples the IronRuby button was missing (although the free space for it was there) J.
According to Microsoft, IronRuby wants itself to be: built on top of the DLR, open source with input and code from the community (under the Microsoft Permissive License), hosted on rubyforge.org and a clean complete implementation of the Ruby language. Pretty cool, huh? Until all the goals are completed, we’re sticking with the very fancy named "pre-alpha version".
The pre-alpha version that you can get from John Lam’s weblog (1) builds, (2) runs, (3) gives really long long long and tangled .NET Fw errors, (4) seems to run faster that the 1.8.6 version of Ruby (3-6x times faster that Ruby, wins or pars most scenarios but performs worse than Ruby in exception handling). Keep in mind that this pre-alpha has not undergone thorough performance testing, but neither has it been performance optimized J
So we’ve seen a little bit about IronRuby on top of DLR and how it performs, and that we can use the .NET Framework from within IronRuby as follows:
require 'System.Windows.Forms'
Win = System::Windows::Forms
f = Win::Form.new
b = Win::Button.new
f.Text = 'hello there'
b.Text = 'Push me'
f.Controls.Add(b)
f.ShowDialog()
Running this code will yield:

So – pretty cool.
Now let’s wire up the Click event on the button and let’s do it Ruby style :D
Close the window, type in:
b.click on |sender, args|
puts 'You pushed me'
end
f.ShowDialog()
and now try clicking the button again!
Now, probably the more obvious question: "Ok, ok, I get it, but where could I use IronRuby?" Basically anywhere J It looks so good and it’s so pretty that I’d use it for almost all the small apps, but you could use it together with Silverlight, or as codebehind in ASP.NET or together with WPF as you can see in this example from ScottGu’s WebBlog.
Finally, before ending this and going to fool around some more with IronRuby, here’s a short how-to-set-up-and-run IronRuby:
- Make sure that you have the .NET Framework 2.0 or higher on your machine (if you read all the way up to here, 99% you have it)
- Download the code archive from iunknown.com (John Lam)
- Unpack the archive and open in notepad the "Build.cmd" file. You’ll notice that the batch makes references to %frameworkdir% and %frameworkversion%. You can now insert two line above:%frameworkdir%\%frameworkversion%\msbuild.exe /p:Configuration=Release /t:Rebuild IronRuby.sln
As to have something like:set frameworkdir = C:\Windows\Microsoft.NET\Framework\
set frameworkversion = v2.0.50727
%frameworkdir%\%frameworkversion%\msbuild.exe /p:Configuration=Release /t:Rebuild IronRuby.sln
And then run the build.cmd.
Note that frameworkdir is generally C:\Windows\Microsoft.NET\Framework\, and your frameworkversion can be anything like: v2.0.50727, v3.0, v3.5.20404.
If everything is ok, in the end you should get the .\bin\release\rbx.exe J and from there on its happy coding.
Looking forward for an Alpha version … [or even an early Beta?]
« .NET 3.0 Summer Rally Next Post
Catching up on my reading »











1:15 am
Thanks for writing up this nice summary of our release! I’m looking forward to getting the next release out the door on rubyforge …