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.

Comments

  1. After the normal compiler for JRuby is complete, I'm going to start on a second compiler that allows compiling a given Ruby class 1:1 to a Java class, producing a class you can construct, with specific signatures you can call from Java code. The idea is that by pointing this compiler at a .rb file with a single Ruby class definition in it you will be able to produce a Ruby-implemented Java class that looks and feels like any other Java class.

    So if it's not perfectly easy to use Ruby features from Java right now, it should be soon.

    ReplyDelete
  2. If you can't wait for the JRuby 1.1 compiler, Groovy has this capability now and a lot more, in the beta 3 just released it even has a joint groovy/java compiler so you can have circular references between Java and Groovy ;-)

    ReplyDelete
  3. Hello Charles: great news. Thanks!

    Hello Graeme: I'll take another look at Groovy, thanks. I would prefer however to not have to be proficient with yet another language (I actively use Common Lisp, Ruby, Java, and Python in my consulting work).

    ReplyDelete

Post a Comment

Popular posts from this blog

My Dad's work with Robert Oppenheimer and Edward Teller

Ruby Sinatra web apps with background work threads

Time and Attention Fragmentation in Our Digital Lives