[IronPython] Running Ruby code from Python, which is running in Ruby

Douglas S. Blank dblank at brynmawr.edu
Mon May 11 19:05:45 CEST 2009


Perhaps you've seen this, but I ran across Tomáš Matoušek’s blog this 
weekend http://blog.tomasm.net/category/ironruby/ where he describes a 
little interactive Ruby shell that works something like:

$ irb.exe repl.rb
rb> class C
rb|   def say_hello caller
rb|     puts "#{caller} says hello to Ruby"
rb|   end
rb| end
=> nil

Now, he switches languages on the fly:

rb> #py

Now, from Python he imports and runs the Ruby class in Python:

py> import C
py> c = C()
py> c.say_hello("Python")
Python says hello to Ruby

I thought I'd try this in the educational DLR editor/shell that we're 
developing in C# (at http://pyjamaproject.org/Pyjama ) and it works! 
There are still some issues (running Python code in Ruby didn't seem to 
work), and you need the latest drop of the DLR (I used 23458):

http://www.codeplex.com/dlr/SourceControl/ListDownloadableCommits.aspx

which isn't stable. But, the proof of concept is fantastic to see after 
all of the hard work. Best of all, the same DLLs allow all this to work 
on Linux and Mac OSX too, thanks to Mono.

This means that you can write and compile a library *once* in whatever 
language you want, use it from other languages, on whatever operating 
system you want. Wow.

Thank you to all those that are making this possible! (And more on our 
DLR IDE soon...)

-Doug

-- 
Douglas S. Blank
Director, Institute for Personal Robots in Education (IPRE)
http://www.roboteducation.org
Chair, and Associate Professor, Computer Science, Bryn Mawr College
http://cs.brynmawr.edu/~dblank  (610)526-6501



More information about the Ironpython-users mailing list