Tomorrow I'll be presenting IronRuby at RubyEnRails 2006. As a result I am making available a preview of the current version. With this preview I'd like to share the progress I've made over the past few months and get some early feedback. Please note that I focused my efforts mainly on the CLR integration - much more than porting the Ruby base class library. In other words, it's far from done.

To get started with this preview you should first get the bits. They currently only include the binaries and a few Ruby scripts to get you started. In a later stadium I will make sure to include the source as well.

Once you have the bits you’ll want to run irb.exe, the interactive Ruby console. To start playing with .NET, reference an assembly like this:

Ruby:
1 

reference "mscorlib"

You should now be able to use the imported types as if they were Ruby classes:

Ruby:
1 
2 
3 
4 
5 
6 
7 

r = System::Random.new
r.Next()

# import a namespace and use a generic type List<T>
include System::Collections::Generic
myList = GenericList.of(String).new
myList("Hello")

You can also do something slightly more interesting such as deriving from a .NET type:

Ruby:
1 
2 
3 
4 
5 
6 
7 
8 

class MyRandom < System::Random
	def Sample()
		0.5
	end
end

mr = MyRandom.new
mr.Next(0, 100)

Or you could implement an interface:

Ruby:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 

class MyType
	implements System::IDisposable

	def initialize(name)
		@name = name
	end

	def Dispose()
		puts "Disposed " + @name
	end
end

myList = GenericList.of(System::IDisposable).new
myList.Add MyType.new("Wilco")
myList[0].Dispose

Ofcourse, there are more interesting things than this to play with. If you happen to have the WinFX February CTP installed, you can get started by including the 'wpf.rb' script. This does some bootstrapping that is required by IronRuby. Here’s what a hello world window in WPF may look like:

Ruby:
1 
2 
3 
4 
5 
6 

require "wpf.rb"

w = Window.new
w.Show
w.SizeToContent = SizeToContent::WidthAndHeight
w.Content = "Hello, world!"

Or you could put together a fancy looking media player:

Ruby:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 

require "mediaplayer/player.rb"
require "wpfextensions.rb" # load some helper methods

# set up reflection
@w.Content.FindName("Reflection").Fill = 
    VisualBrush.new @w.Content.FindName("MainGrid")

me = @w.Content.FindName("Player")

# setup auto replay
me.MediaEnded += proc { |sender, e| me.Clock.Controller.Begin }

me.load "c:\\WINDOWS\\system32\\oobe\\images\\intro.wmv"

So much for a few examples to get you started...

I’d love to hear from you. What do you think of the current release? Which things would you like to see first next? All feedback is welcome.

Although I have no direct experience, this stuff looks fantastic! Keep on your great work.
I have tried several test programs but ran into some problems with parsing the ruby. It appears that the parser is still weak. Deafult parameters and regular "%" strings (not sure what they are called in ruby since I am learning ruby myself)

example:
rcsid = %w$Id: myfile.rb,v 1.0.0.0 2006/01/01 15:00:03 mark $


Having said that things look great! Keep up the great work and I look forward to the source and more opportunity to contribute/help out.

-mark
BTW: Not sure if you are considering putting IronRuby up in an open repository like sourceforge or something but I thought I would mention http://www.codeplex.com/ which is a MS/TeamFoundationServer code repository. IronPython is moving there from gotdotnet.

-mark
Mark: I plan on sharing a list of known caveats/missing features/todo's in the near future to make sure people know what they can expect. The more Ruby specific features are currently very weak, mostly because 90% of the time spent so far has been on the CLR integration (dealing with interfaces, generics, databinding, etc.). At some point (when the integration is "good enough for now") I will move the focus to Ruby and deal with the missing language features first.

Thanks for the pointer to codeplex. I will definitely consider it.
I am interested if you are going to make it open-source, because I only see a dll for the ruby interpreter
Yes, at some point I will make it open-source.
Would you mind contrasting what you've done with John Lam's RubyCLR? They seem very similar.
Scott: The main difference is that IronRuby is a Ruby implementation for .NET, while RubyCLR is merely an extension of the already existing Ruby compiler/interpreter and provides a bridge between (native) Ruby and .NET.

The advantage of John's approach is that he doesn't need to reinvent the wheel (Ruby as a language) to integrate with .NET. With my approach I bring all of the .NET features to the core of Ruby. This includes, but is not limited to, a JIT compiler, the .NET GC, debugging support, and so on. Another advantage I think my approach has is that the integration is easier and can be more optimal. All I really have to deal with is a code base that is entirely written in and on top of .NET. Moving between the managed and unmanaged world is usually more involved/expensive.
Thanks for the clarification on the differences with John Lam's work. So how is your project different from this one? :) http://plas.fit.qut.edu.au/rubynet/
Oran: Apart from a few details (such as they using a home grown PE writer/reader) their project seems very similar. I've started some prototyping during Christmas last year, when I could absolutely find no serious announcements or existing Ruby for .NET projects. As you may understand, I kind of got scared when I first heard that there were other efforts to implement Ruby for .NET.

One reason I did continue my work was that they had no material and planned to release an alpha version mid 2006. I guess only time will tell more about both projects :).
I downloaded your IronRuby compiler today, and simple tests so far work with Mono. Congratulations!

Miguel.
That's great to hear, Miguel. So far I don't have any reason to fear breaking compatibility with Mono in the future either, so all should be good.
We are weighing a move away from JRuby's current method of implementing a Java interface in Ruby toward something like your "implements". The debate currently rages between overloading include or introducing a new method/keyword for interfaces because of their different semantics.

However that debate turns out, I might make one suggestion to you: Ruby uses verbs for such things, not adjectives, so it would probably be more proper to use "implement". "implements" will look pretty weird alongside "include".

class MyImpl
implement SomeInterface
include Enumerable
end

I'm also debating something that makes the interface implementation more explicit, like:

class MyImpl
implement SomeInterface do
def method1; ...
def method2; ...
end
end

If there's a mailing list I'd love to join it; otherwise, I'd love to discuss offline.
Sorry, that should have been codified:

Ruby:
1 
2 
3 
4 

class MyImpl
  implement SomeInterface
  include Enumerable
end



and

Ruby:
1 
2 
3 
4 
5 
6 

class MyImpl
  implement SomeInterface do
    def method1; ...
    def method2; ...
  end
end

Wilco, This project looks great. Getting ready to test it out in mono (os x) and on windows myself. If it works good this will more than likely find it's way into a game or two for the xbox/pc.

Time will tell. Keep up the good work. I like your napproach best so far.
Hi Wilco,
when I type
myList = GenericList.of(String).new
myList("Hello")
I found an error:
NoMethodError:undefined method 'myList' for main:Object
why?
Hello! Good Site! Thanks you! iwcsvhdsmyt
Thanks for this site! <a href=http://q.togzo.cn>q.togzo.cn</a> <a href=http://oo.xbgcy.cn>oo.xbgcy.cn</a> <a href=http://vgpw.qeyef.cn>vgpw.qeyef.cn</a> <a href=http://drkv.nkjwa.cn>drkv.nkjwa.cn</a> <a href=http://e.osqkp.cn>e.osqkp.cn</a> <a href=http://zzh.swhge.cn>zzh.swhge.cn</a> <a href=http://m.lvegk.cn>m.lvegk.cn</a> <a href=http://re.gbfwj.cn>re.gbfwj.cn</a> <a href=http://dew.fqtpq.cn>dew.fqtpq.cn</a> <a href=http://z.muuic.cn>z.muuic.cn</a> <a href=http://j.avfaw.cn>j.avfaw.cn</a> <a href=http://kw.avfwp.cn>kw.avfwp.cn</a> <a href=http://zydr.zeoru.cn>zydr.zeoru.cn</a> <a href=http://cvmgw.dsarf.cn>cvmgw.dsarf.cn</a> <a href=http://zdvvd.zhqde.cn>zdvvd.zhqde.cn</a> <a href=http://qe.wcknd.cn>qe.wcknd.cn</a> <a href=http://ncyp.qpeeh.cn>ncyp.qpeeh.cn</a> <a href=http://ccrcz.lvegk.cn>ccrcz.lvegk.cn</a> <a href=http://r.avfaw.cn>r.avfaw.cn</a> <a href=http://rdjbn.ykksc.cn>rdjbn.ykksc.cn</a> <a href=http://fgthv.bxeci.cn>fgthv.bxeci.cn</a> <a href=http://tlcl.mywev.cn>tlcl.mywev.cn</a> <a href=http://ptx.nkjwa.cn>ptx.nkjwa.cn</a> <a href=http://yylm.qsqcj.cn>yylm.qsqcj.cn</a> <a href=http://owb.ykrjd.cn>owb.ykrjd.cn</a> <a href=http://osbn.afsyf.cn>osbn.afsyf.cn</a> <a href=http://bcklf.zhqde.cn>bcklf.zhqde.cn</a> <a href=http://og.ykrjd.cn>og.ykrjd.cn</a>
Thanks for this site! <a href=http://dt.pwfee.cn>dt.pwfee.cn</a> <a href=http://ylwdt.hdvqt.cn>ylwdt.hdvqt.cn</a> <a href=http://cwtxj.arvse.cn>cwtxj.arvse.cn</a> <a href=http://hutrn.zefda.cn>hutrn.zefda.cn</a> <a href=http://e.rjrxz.cn>e.rjrxz.cn</a> <a href=http://za.edpzh.cn>za.edpzh.cn</a> <a href=http://jcpyq.bjpoe.cn>jcpyq.bjpoe.cn</a> <a href=http://u.yqpzu.cn>u.yqpzu.cn</a> <a href=http://ei.akoqr.cn>ei.akoqr.cn</a> <a href=http://yiew.arvse.cn>yiew.arvse.cn</a> <a href=http://lbor.xawdt.cn>lbor.xawdt.cn</a> <a href=http://ddfn.punwg.cn>ddfn.punwg.cn</a> <a href=http://lh.vrbzq.cn>lh.vrbzq.cn</a> <a href=http://zp.edpzh.cn>zp.edpzh.cn</a> <a href=http://xdk.jekxc.cn>xdk.jekxc.cn</a> <a href=http://ivhz.fizyn.cn>ivhz.fizyn.cn</a> <a href=http://fm.conxj.cn>fm.conxj.cn</a> <a href=http://tmn.ugkhk.cn>tmn.ugkhk.cn</a> <a href=http://qjq.vzpwo.cn>qjq.vzpwo.cn</a> <a href=http://o.dhiam.cn>o.dhiam.cn</a> <a href=http://uglsq.vqrkp.cn>uglsq.vqrkp.cn</a> <a href=http://e.syhzz.cn>e.syhzz.cn</a> <a href=http://dfpo.udjqb.cn>dfpo.udjqb.cn</a>
Your message will be encoded/formatted when it is displayed. If you want to post code, please put the code inside [code=X][/code] tags, where X is the language of your code (C#, ASPX, SQL, etc).
Name:
Email:
(will be encoded using JavaScript to keep it functional and prevent it from being picked up by spammers)
Url:
 
Message:
3 + 3 =