Frequently Asked Questions

Question 1: What about the cost of marshaling calls and data to .NET? Is it reasonable to use .NET-interop technologies from Ruby or is it better to wait for native .NET compiler/interpreter for Ruby?

At this stage little is known about the runtime performance of rubydotnet. Booleans, ints, floats, doubles and strings are marshalled by value. Everything else is marshalled by reference by the use of proxy objects. In the current incarnation of rubydotnet call marshalling is implemented in Managed C++ Extensions/IJW, which is the fastest interop facility available for .net. I am investigating the use of P/Invoke, so I can port the majority of the C++ code to C# to make it easier to support both Microsoft CLR and Mono. In the long run I hope to see a version of ruby that executes entirely on .net. The current ruby implementation is not thread safe and having two independent garbage collectors is problematic.

Question 2: Are there some gotchas in the process of marshalling Ruby data types into .NET?

Yes. Ruby strings are mutable but are still marshalled by value to a .net System.String for convenience, so you need to be aware that subsequent changes to the original string will not be seen in .net. If the .net string is marshalled back to ruby it will be a new copy too. Ruby integers can be of arbitrary size. If a ruby integer is small enough to be represented by a .net int it will be, otherwise it is converted to a float with loss of precision as a result.

Question 3: Is it possible to use ruby classes as native objects on .NET side? Some examples?

You cannot define new types in ruby. In order to do that you need to generate a .net assembly, which rubydotnet doesn't do. You can however implement .net interfaces from ruby and use the objects from .net. See Lesson 4 in the sample.

Question 4: How is your technology related to the saltypickle RubyDotNet bridge If they are very different, what approach seems better and why?

The two projects are rather similar. The saltypickle RubyDotNet initially used sockets for communication and still has that option, this affords the bridge extra flexibility, but also adds to the complexity of the implementation. I try to keep my own rubydotnet as simple as possible.

Question 5: Do you plan to regularly maintain and develop rubydotnet, or is it for fun only?

I plan to use rubydotnet for my own development purposes and will add features to it as I see necessary and fix bugs as I find them.