Thursday, November 13, 2008

Enough with Java Ports

Or rather, enough with requiring Java ports. Though I guess the encouragement of genetic diversity has its pros.

I also applaud Jython, JRuby, JBullet, and many more. I was once working on an ImageMagick and RMagick port for Java/JRuby. I didn't expend the time to make enough progress, though I believe it could work out well.

My concern is that the "Java apartheid" coupled with lack of direct support for running C/C++/DLLs directly on the JVM leads to too much wasted effort. And I get the point of how much easier it is to pick up and use a jar (wherever you are) vs. picking up and using native libraries.

There are some (HUGE!) gotchas, but I think it should be possible to run native code directly in Java. Two techniques:
  1. Use JPC as a base for running x86 DLLs (or Linux so files or whatever) as if they were JVM bytecode, or
  2. Compile C and C++ (and others in GCC) directly to JVM bytecode so that structs, classes, namespaces, and so on all map nicely and are directly available from other JVM languages (like Java even).

I'm don't plan to work on this myself, but I think it's a right thing to be done. And meanwhile, I'm tempted to get back into coding C++. (Been a while.)

Actually, I double-dog-dare anyone to make a C++ to JavaScript compiler.

2 comments:

  1. This is all pie-in-the-sky, but unless you actually need x86 binary compatibility, you're much better off with NestedVM.
    http://nestedvm.ibex.org/

    ReplyDelete
  2. Curt, thanks much for the link. I could still imagine wanting to use an arbitrary precompiled file, but NestedVM (to the extent it works well) could solve many cases.

    ReplyDelete