Calling Ruby from within .net

September 30th, 2007 Aaron Junod Posted in Source, Implementation, Samples, IronRuby No Comments »

Cory Foy posted a very in depth post explaining how to call Ruby from within .net. This post is much more then just code, it really digs deep into how IronRuby is working under the covers, very informative! Cory describes a bit on how the RubyEngine is working under the covers, and how the AST (abstract syntax tree) plays into the execution. Much like Cory, though, I was unaware that the ?? operator has been added to .net 3.0, and that’s great. (c#)?? == (ruby)||= Get it? :)

On a related note, Phil Haack also updated the wiki with a sample on executing Ruby in .net here.

AddThis Social Bookmark Button

Mixing in kernel

August 2nd, 2007 Aaron Junod Posted in Source, Implementation, IronRuby No Comments »

Yesterday I posted on my desire to port over attr_accessor, which I’m realizing is a lofty goal for myself, but we’ll see where it brings me. The IronRuby team has already done some of the legwork, though. If you search the source for attr_accessor you find a comment about it in Ruby\BuiltIns\ModuleOps. So if I’m following correctly, a module, much like in MRI, is a set of code that can be thrown around, and usually used as a mixin to another class. For those unaware of a mixin, think of it simply as arbitrary code you can add to classes, very much like extension methods for those of us .net geeks.

As I often do, I got sidetracked here, and jumped over to Kernel.cs. Just yesterday I was having a conversation with Jason, the other guy that has posted here so far. He’s been diving into the Ruby source more then myself, and was explaining how Kernel includes many of the common methods, and just simply gets mixed into object. He then started down how it gets into irb, but I think I spaced out at that point.

As I’m looking at kernel, I find the code below :

Code (c)
  1.  
  2.     [RubyExtensionClass("Object", typeof(object)), Includes(typeof(Kernel))]
  3.     public static class ObjectOps {
  4.  

So from what I can tell, IronRuby is doing the same thing under the covers. That shouldn’t really surprise me, but I was really impressed with how classes seem to be getting mixed in on the managed side, the attribute above is very clear and clean, and stays very close to “the Ruby way”.

AddThis Social Bookmark Button

Yashlabs fixing some IronRuby bugs

July 27th, 2007 Aaron Junod Posted in Implementation, IronRuby 2 Comments »

Josh Nursing put up a great post on his initial experiences with IronRuby. He walks us through his installation, including addressing a possible issue with the path of the .net framework. He then walks us through setting up vs.net express edition to work with IronRuby.

The best part is he outlines two bugs, one with string concatenation, and the other with math as Antonio Cangiano had discussed. After outlining them, he actually walks us through fixing them!

Edit :

Josh isn’t the only one fixing the math bug. Seo Sanghyeon also posts his fix, and even includes a packaged patch! With community participation like this, IronRuby is sure to be a success.

These are both great posts that anyone interested in IronRuby should check out, especially if you think you’ll be diving into how IronRuby is actually implemented.

AddThis Social Bookmark Button