4 ms·
Yes, sort of. Or maybe kind of not? I am not sure I'd call what Graal is doing "interoperability", because you essentially pull everything into that VM, inste
by mpweiher 9y ago
Yes, sort of. Or maybe kind of not?
I am not sure I'd call what Graal is doing "interoperability", because you essentially pull everything into that VM, instead of interoperating with it where it is.
So they "interoperate" with C by making a C compiler that creates a Graal-compatible AST, and as far as I can tell, the only way of interoperating at this point is creating a new Graal compiler.
- Apanatshka 9y agoWhat I've gathered about Graal is that once you have a compiler for the platform, Cross-Language communication on a hot path gets optimised to near-zero cost.
- mpweiher 9y agoExactly. You're not really crossing boundaries any more, you just have different surface-syntaxes for "the Graal language system".
- merb 9y agowell your statement is neither true nor is it false. See: http://www.graalvm.org/docs/reference-manual/languages/llvm/ http://www.graalvm.org/docs/reference-manual/languages/llvm/ for example. Basically you generate bitcode and can run the bitcode on graal. However you can still load native libraries into Graal and access them, you can't probably access them directly in java without a wrapper (I'm not sure about that yet). So basically you compile your C/C++/Rust Code to BitCode instead of Object Files/Binaries and run that BitCode on Graal. I.e. with java: Context polyglot = Context.newBuilder() .allowAllAccess(true) .option("llvm.libraries", "/usr/lib/libcurl.dylib") .build(); Source source = Source.newBuilder("llvm", new File("hello.bc")).build(); Value cpart = polyglot.eval(source); cpart.getMember("main").execute(); Whereas hello.gc is: #include <stdio.h> #include <curl/curl.h> int main() { CURL *curl = curl_easy_init(); if(curl) { CURLcode res; curl_easy_setopt(curl, CURLOPT_URL, "http://example.com"); http://example.com"); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } printf("Hello from GraalVM!\n"); return 0; }