Thursday, September 20, 2007

JRuby and Jython: a one way street?

This is just personal experience: JRuby and Jython are great when you want to use existing Java libraries and utilities from inside Ruby and Python programs. (Warning: Jython does not implement all of Python: many of my Python programs that use list comprehensions, generators, etc. simply do not work yet.)

However, I am skeptical of the utility of doing the reverse: using modules of Ruby or Python code inside large Java applications. I would like to hear about examples of this that don't just use Ruby or Python as embedded scripting languages.

BTW, since I usually prefer using the native C versions of Ruby and Python, I set up my bash environment to create aliases for running the JRuby and Jython command line tools:
## for Jython and JRuby without messing up PATH and native Ruby and Python:     

alias jython=/Users/mark/bin/jython2.2/jython
alias jruby=/Users/mark/bin/jruby-1.0/bin/jruby
alias jirb=/Users/mark/bin/jruby-1.0/bin/jirb
alias jgem=/Users/mark/bin/jruby-1.0/bin/gem
export JRUBY_HOME=/Users/mark/bin/jruby-1.0
I also edit my jirb and JRuby gem shell scripts to explicitly set the path to jruby. Now I can easily run the JRuby and Jython for just those occasions when I want to use Java class libraries.