4 ms·
Can you explain why you would code java this way instead of dropping down to C?
by apalmer 6y ago
Can you explain why you would code java this way instead of dropping down to C?
- whizzter 6y agoProbably because they started out in Java and don't want a full rewrite once they've gotten this far (might be that they don't have many C++ devs anyhow). I remember working on similar codebases 10 years back when J2ME games were still a thing (J2ME runtimes usually had horrible GC's and some people really went overboard in trying to avoid them) and it wasn't that fun at all (Even if the questDB codebase that is linked elsewhere in this thread seems to be saner). Also JNI for calling C/C++ code is fairly bad and error prone (if you want to combine code), JNA is better but i think this is one of the bigger reasons that Oracle is funding GraalVM is that it promises "seamless" interoperability and breaking up things into Java and C/C++ parts might be a good option in the future.
- pjmlp 6y agoJNI replacement is called Panama it doesn't have anything to do with GraalVM. GraalVM is the new name of MaximeVM one of the JVM meta-circular JVMs. Other well known ones being JikesRVM and SquawkVM. What Oracle and others in the Java community are doing is reducing the need to drop down to C with support for value types and more fine grained control over native memory. Java 16 will have the first preview release of the new low level memory APIs.
- whizzter 6y agoThe meta-circularity is part of the impl details, cross-language calling (Java/JS/LLVM) seems to be the main selling point of it, so if you want GC-less logic then Clang->LLVM then running on the JVM is an option, no idea if it also simplifies native bindings though (that is more of a Panama issue and improving that is a good idea aswell).
- pjmlp 6y agoProductivity and safety of Java. Those unsafe bits are a tiny portion of the overall code.