GraalVM and other similar projects will add a substrate of the JVM to the resulting binaries. That’s not what I’m thinking. What I would love to have is:
- Taken the two equivalent Java and C++ HelloWorld programs below:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World");
}
}
#include <iostream>
int main() {
std::cout << "Hello Worldn";
return 0;
}
- Compile both to native code in a way that both generated binaries (assembly code) are very similar to each other if not the same.
I’m completely aware that Java has Garbage Collector and C++ does not, but that’s ok. This new language (very similar to Java) would provide a delete
keyword to deallocate the object and free its heap memory. In other words, you could finally program in a language similar to Java and do memory management yourself.
Example:
Map<String, String> map = new HashMap<String, String>();
// (...)
delete map; // I'm done, bye.
NOTE: I’m not trying to convince anyone that Java is good or bad. I’m also not trying to advocate in favor or against the JVM. I’m just wondering why there was never an attempt to write a compiler for a language very similar to Java. Like I said, GraalVM is not what I’m looking for, as it it a compiler for the Java bytecode, not for the Java language.