Saturday, November 04, 2006

Annotations instead of C code for JNI

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.

2 comments:

Anonymous said...

a) Java is already a steaming pile of shit. If you take shit from one room to another, its still shit

b) Use swig

c) Why did you stop taking anonymous comments

Slava Pestov said...

I stopped taking anonymous comments because of spam.

Arseholes pay suckers in third world sweatshops to solve capatchas all day long and post spam in blogs.