Ironing code, geek t-shirts and even presentations!


IronRuby 0.3 Has Been Released!

Great news! As Jimmy Schementi describes it – the “conference-driven development schedule” of IronRuby brings us some news for the MIX09 conference. It’s the 0.3 version of IronRuby!

IronRuby 0.3 is out!

So what’s new in 0.3?

  1. IronRuby now passes 10% more of the RubySpec than v0.2 has. Make sure to check in order to get up-to-date statistics.
  2. Better .Net interoperability – you can now call generic methods and implement interfaces!
  3. More! you can read about all changes in the CHANGELOG.txt file that you’ll find in the zip.

Grab it:


Make Your Application Extendable Using the DLR

It’s very common for applications to have a way to extend them. Extensibility comes in various ways and have multiple names too – plug-ins, add-ins, addons, etc. It seems, though, that one kind of extensibility was left to the very few – application macros.
The concept is very simple – You don’t need to create a special Dll, implement a specific interface and register it somehow, you don’t even have to install an IDE. All you have to do is to open the relevant window, write some code and voila – you’ve extended the application.

What is this post about?

I’ll start with the result.
I built a simple application – it has a textbox, a “Send” button and a larger textbox for the application output. The flow is very simple – the user writes text in the textbox, hits “Send” and a “Hello” message appears in the larger textbox:

Extending Applications using the DLR - Sample #1

The power lies in the button on the bottom of the form - “Extensions”. Clicking there will open the extensions dialog, where you can write a macro which will be run after the user clicks “Send”. The users can choose the language for their macro, which will be one of the DLR’s languages – IronRuby or IronPython. After the user writes the code and hits “Save”, the application is extended!

Extending Applications using the DLR - Sample #2


Now when the user clicks send, look what happens:

Extending Applications using the DLR - Sample #3

This sample is very simple but it took me about 20 minutes to get it done. It’s just magic!

How was it done?

Well, all the credit goes to the DLR. This amazing little thing, makes it soooo easy to integrate dynamic languages into the .Net environment, that it’s a shame not to do so.

The heart of this application is the ExtensionRunner class and its Run method:

public static bool Run(Form1 frm, string code, bool rubyCode)

The method receives 3 parameters – the form object to pass to the executed code, the code that the user has written and a boolean value indicating whether it’s ruby or python code.

Firstly, I declare a ScriptScope and a ScriptEngine variables and fill them with the chosen language implementation. Because all DLR languages implement the same interfaces and classes, this is the only language-related code here. After that, the code will fit every DLR language. This means that adding IronScheme and Nua here, for instance, will be a matter of seconds:

scope = null; ScriptEngine engine = null; if (rubyCode) { engine = Ruby.CreateEngine(); scope = Ruby.CreateRuntime().CreateScope(); } else { engine = Python.CreateEngine(); scope = Python.CreateRuntime().CreateScope(); }

Now we declare variables that the macro code will be able to use. We declare 2 variables:

  • frm – which is the form object. you wouldn’t want to do that in your application, the right way will be to pass a class with targeted functionality for the extensions.
  • return_value – the extension will put a value here. It’s a boolean value which indicates whether we should continue with the regular flow of the application after the extension has been executed or stop.

"frm",frm); scope.SetVariable("return_value", false);

The rest of the code is pretty straight forward – I create a ScriptSource object from the given code and execute it. Then I get the return_value value and return it to my main application.

// Run the code!
ScriptSource source = engine.CreateScriptSourceFromString(code, SourceCodeKind.Statements); source.Execute(scope); // Get the return value bool retVal = scope.GetVariable<bool>("return_value"); return retVal;

This is it. The other code of the application is just a regular WinForms code so I won’t deep dive into it.


In conclusion, the DLR makes it very simple to run dynamic languages from your .Net code. I showed you here only one of the possibilities that are made available with this kind of integration.

Go ahead and try!

Download the source code

All the best,

Like it? Share it: Loves soccer? Kick it  | Angry? Shout it  | In DA ZONE? DZone it

IronRuby, IronPython and DLR Daily Builds RSS Feed Is Available!

With the help of Harry Pierson (AKA DevHawk), there is an RSS feed that will notify you when a new nightly build is available!image 
The builds are daily and you get the latest versions of IronRuby, IronPython and the DLR in Silverlight or desktop versions.

So all of you early adapters, go ahead and subscribe to the feed!

Comment: the files in the feed are the built files, not the source code.


IronLanguages and Cross-Platformability

Most dynamic languages can run on multiple platforms. IronPython and IronRuby are no exception. The dev teams are investing lots of resources in order to make this happen because of the importance of this feature to the community.

IronPython and IronRuby can be run on top of Mono, which enables you to run .Net applications on top of different platforms, including Linux, BSD, Mac and more.


There are some great posts that show you how to do that:

Enjoy the cross-platformability! :)

IronRuby Code Repository Changes

Starting from today, you will not get new updates from the IronRuby SVN code repository. The repository has been moved to github, and SubVersion has been replaced with Git.

If you want the source code, you’d need to adjust your code with the new changes.

If you don’t need the code, only the builds, you can now download the latest 0.2 version as a zip file (that contains the needed DLLs and batch files). Soon enough you’ll be able to download daily builds as well – so the need for the source code reduces or even disappears for those who only wish to work with IronRuby.

The 0.2 version, the daily builds (coming soon) and the links to the Git repository can be found on the download page at:

All the best,
Shay. Was Recently Updated With a Brand New IronRuby Logo!

The site (the official IronRuby site) has recently changed it layout from a kind of childish layout to a slicker one.  The new layout comes with a new IronRuby logo! here it is:

ironrubylogoIt’s a nice and simple logo – stays true to its roots :)

Some other updates to the site – the Roadmap page has been updated and it now contains the “must-have” and “nice-to-have” items for the first release of IronRuby. Quite an interesting list, worth a look.


All the best,

IronRuby Tip: Ruby String and ClrString

When you use IronRuby to execute some C# code, for example, and the C# code returns a string, pay  IronRuby Tip: Ruby String and ClrStringattention that the string is not a Ruby string!
The type of the object you receive is ClrString. ClrString is the equivalent of System.String in IronRuby, all the System.String methods will work on ClrString objects, but Ruby’s string methods will not (and vice versa).

For example:

clr_string = MyCSharpNameSpace::MyClass.ReturnString()

clr_string.IndexOf("something") # This will work
clr_string.EndsWith("something") # This will work

clr_string[0..2] # This will NOT work
clr_string.index("something") # This will NOT work

As you can see, the System.String methods work but the Ruby string methods don’t.

What to do?

If you want to use a System.String as a Ruby string, all you have to do is call to_s! just like that:

clr_string = MyCSharpNameSpace::MyClass.ReturnString()

clr_string = clr_string.to_s # Converting the ClrString to a Ruby string

clr_string[0..2] # This will WORK!
clr_string.index("something") # This will WORK!

Just to make clear – you will not be able to use System.String methods after the conversion to a Ruby string… One language at a time, folks, one language at a time :)

All the best,

Getting Started With Dynamic Languages

I've grouped together some resources and blogs for all of you out there who are willing to start working with dynamic languages that are built on top of the DLR. Enjoy!

IronRuby IronRuby


Currently you'll have to get the code from the IronRuby SVN repository (svn://  OR HTTP:// and build the project yourself.
Justin Etheredge has posted a step-by-step walk-through on his blog.


Recommended Blogs

IronPython IronPython


You can get the installer from the IronPython codeplex homepage:


Recommended Blogs

IronScheme  IronScheme


You can get the installer from:


The Dynamic Language Runtime DLR - The Dynamic Language Runtime

There is no need to download the DLR code separately because it already comes with the installation of the other languages. If you want to write your own language on top of the DLR, this is the place to start for you.


You can get the binaries and the code from the codeplex homepage:


Hope it helps,

kick it on

How to Debug and Run IronRuby Code From Visual Studio

This isn't a trivial thing to do until the IronRuby Visual Studio Integration component is out. So here are the steps in order to achieve that:

1. In Visual Studio, click on File-> Open -> Project/Solution

How to Debug and Run IronRuby Code From Visual Studio

2. Select ir.exe from the [IronRuby code directory]\trunk\build\debug (or release, depends on how you've compiled the code)

How to Debug and Run IronRuby Code From Visual Studio

3. Right click ir.exe in Solution Explorer and select Properties

How to Debug and Run IronRuby Code From Visual Studio

4. In Command Arguments, with "-D [path to code file]" where [path to code file] will be the full path to your ruby file.
For example, -D "c:\dev\IronRubyTest\test.rb".

How to Debug and Run IronRuby Code From Visual Studio

That's it! you can debug your IronRuby code file now!


This post was greatly inspired by the IronPython solution that was posted by Harry Pierson on his blog.


IronRuby Tip: Access .Net Indexers

The Problem

IronRuby Tip: Access .Net Indexers  Currently, if you have a .Net class you want to access via IronRuby, and you have an indexer there (like myObject[2]), you won't be able to use the indexer with brackets [] from IronRuby. You'll get an exception.

The Solution

Use get_Item(index) instead (pay attention to casing).


my_dataset.Tables[0] # <-- This won't work
my_dataset.Tables.get_Item(0) # <-- This will work great!
All the best,