Annotations instead of C code for JNI
Saturday, November 4, 2006
A Java programmer has realized that JNI is a steaming pile of shit. He writes:
*The more I think about it, the more I think something like the
following would make sense:
*
@Native(dll=foo,function=bar)
public void bar();
Damn right it makes sense. There is no good reason one should have to
program in C, and learn the internals of their language runtime, to call
C libraries, even those involving structures, callbacks, and so on.
The Java OpenGL binding is 40,000 lines of Java code, including some
hairy Java and C source generation, and a complicated build process
(when I was doing my Java game, I never managed to get JoGL to compile,
even after downloading half a dozen dependencies and playing with the
build.xml. I always used the binary packages).
The Factor OpenGL binding is less than 2,000 lines of code consisting of
a handful of source files. We also have bindings to FreeType, Cocoa,
WinAPI, a USB library, and various other things, all implemented in
Factor, without huge amounts of boilerplate or C code.