JRuby can access classes implemented in pure Java code. Clojure can generate a class file. Therefore it's straightforward for JRuby to access classes implemented in Clojure.
First I define a class with a method in plain Java.
MrJava.java:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MrJava { | |
public MrJava() { | |
} | |
void hi(String name) { | |
System.out.println("Good afternoon " + name + ", how are you?"); | |
} | |
} |
It gets better; you can use Clojure's persistent data structures from JRuby as well: http://github.com/technomancy/clojure-gem
ReplyDeleteUsing the STM is still not seamless since JRuby's Exception proxies get in the way of transaction retries, but with a little more work it could be done.
Thanks Phil for letting me know it!
ReplyDelete