Thursday, February 19, 2015

Java Frontend with Giws

The Java Frontend has been updated to work with the Giws JNI wrapper generator, this lets you create Java objects and call their methods from C++, and also from Rusthon when using the C++ backend. Giws supports all of Java's primitive types like numbers, strings, and arrays; one problem is class constructors see this git hub issue.

The new syntax is documented in the wiki, here. Java source that you embed in the markdown is compiled with javac, xml source in the markdown that is marked with @giws will run giws and generate the c++ wrappers. In rusthon code using import jvm will link the final exe to and also create an instance of the JavaVM.

Jython Hello World

source code:

See the source code in to see the xml wrapper code the exposes Jython's PythonInterpreter, this simple example only wraps the exec method.

rusthon input

import jvm
jvm.load( 'jython.jar' )

def main():
 interp = jvm( PythonInterpreter() )
 script = "print 'hello world'"

c++ output

using namespace org_python_util;
int main() {
 auto interp = std::make_shared(__javavm__);
 auto script = std::string("print 'hello world'");
 return 0;

Similar projects that allow Java to be used in CPython: Py4J, and Jpype.


  1. I am wondering which one is better between PythonJS and Coffeescript.

  2. One of the major features of Rusthon is having a single meta-language, write once and translate to the language you need. CoffeeScript, is not typed, and only targets JavaScript.