Live data from Hacker News

GraalVM: Run Programs Faster Anywhere

graalvm.org

21–30 of 218 posts

Re: GraalVM: Run Programs Faster Anywhere

#21
Might this (today, tomorrow) become another way to get access to the wonderful Lucene from non-Java environments? A long, long time ago there was a GCJ-based solution, but it was never loved much (either the port or GCJ itself). SubstrateVM looks potentially delicious here

edit: lol: talk about a low blow!

> The community version does not support DWARF information. The enterprise version supports all native tools that rely on DWARF information, like debuggers (gdb) and profilers (VTune).

Re: GraalVM: Run Programs Faster Anywhere

#22

This project is remarkable! Really excited to see where it goes. The biggest problem I see so far is sparse docs on interop. I see docs with a trivial example of importing simple types from java and using them in node, which is amazing! However, this is pretty far from a real world example. In the real world there are deep type graphs and dependencies and functions that look like IWidgetInterface createWidget(IAbstra…

Thanks for the feedback. We will definitely improve the polyglot docs in the next weeks. There is lots more to show.

Are you calling from Java? Then there are more examples here: http://www.graalvm.org/docs/graalvm-as-a-platform/embed/

Also some of the examples on the website use interop: http://www.graalvm.org/docs/examples/

Re: GraalVM: Run Programs Faster Anywhere

#23
post #18

Graal dev here. If you want to checkout all the sources/licenses of GraalVM CE. They are here: Graal: https://github.com/oracle/graal (GPLv2 with CPE) JavaScript with Node Integration: https://github.com/graalvm/graaljs (UPL - BSD license) Ruby: https://github.com/oracle/truffleruby (EPL, GPLv2, LGPL) R: https://github.com/oracle/fastr (GPLv2) Python: https://github.com/graalvm/graalpython (UPL - BSD license) LLVM/Su…

Thanks! Out of curiosity — if I built an application with truffleruby, could I distribute it as a JAR (provided that it was run under JDK 9)? Are there ways to call out to Java like JRuby? Having some difficulty finding documentation around this.

> if I built an application with truffleruby, could I distribute it as a JAR

Yes there is a Java embedding API.

http://www.graalvm.org/docs/graalvm-as-a-platform/embed/

> (provided that it was run under JDK 9)

It can run on 8. It'll be fast on JDK 9 or 10 because these have the interface to use Graal.

> Are there ways to call out to Java like JRuby?

JRuby compatible interop:

https://github.com/oracle/truffleruby/blob/master/doc/user/j...

Our own interop:

https://github.com/oracle/truffleruby/blob/master/doc/user/p...

> Having some difficulty finding documentation around this.

https://github.com/oracle/truffleruby/tree/master/doc

Re: GraalVM: Run Programs Faster Anywhere

#24
post #7

Am I correct in reading the license in Github that this is all GPL? Albeit GPL2 but still not some Oracle proprietary license. "One VM to rule them all" reminds me of Parrot VM (for Perl 6). Looks like development slowed down a year or two ago. Back then, it got me excited as it looked like the "open source community" alternative to "Big Corporate Java". https://en.wikipedia.org/wiki/Parrot_virtual_machine

I was very interested in Parrot VM for a while too for the same reasons. I always liked the idea of language interoperability and being able to use the best libraries of each language. This brings me to a question I have had for a while, why do we even have so many language specific libraries for common tasks instead of more "universal" libraries with bindings for each. Of course these exist, but I feel like this sho…

Languages usually have a foreign function interface (FFI for short) to interface with external libraries. That's not as easy as one could expect, even for languages that are "closer to the metal": I remember Pascal and C different parameters passing conventions, left to right vs right to left and the cleaning of stack... you need to use compiler directives and careful thinking. Also which memory manager you use and the fact that DLLs might not "see" the same address space.

You mention Python that they say has an easy FFI with C. That's nice but it's usually used for the performance more than for reusing code.

Re: GraalVM: Run Programs Faster Anywhere

#25
post #18

Graal dev here. If you want to checkout all the sources/licenses of GraalVM CE. They are here: Graal: https://github.com/oracle/graal (GPLv2 with CPE) JavaScript with Node Integration: https://github.com/graalvm/graaljs (UPL - BSD license) Ruby: https://github.com/oracle/truffleruby (EPL, GPLv2, LGPL) R: https://github.com/oracle/fastr (GPLv2) Python: https://github.com/graalvm/graalpython (UPL - BSD license) LLVM/Su…

Thanks! Out of curiosity — if I built an application with truffleruby, could I distribute it as a JAR (provided that it was run under JDK 9)? Are there ways to call out to Java like JRuby? Having some difficulty finding documentation around this.

Yes you will be. But we use a different interface. Checkout this guide: http://www.graalvm.org/docs/reference-manual/polyglot/

Select your start and your target language and it will show you an example. Its a very basic example, but it basically works with all Java types. We will provide better docs soon.

Re: GraalVM: Run Programs Faster Anywhere

#26
Can someone please explain this?

> Are you working on a Java application? Do you want a faster runtime? Enhance your code with JavaScript!

First, the JVM already has the Nashorn JS engine. Second, if I'm "working on a Java app", that means that it's already running in a JVM. Where does the faster runtime come from? Is executing JS from Java using Graal faster than running actual Java code? Is it just faster than Nashorn? Something else?

Re: GraalVM: Run Programs Faster Anywhere

#27
Truffle makes it possible to implement a JITed dynamically-typed language simply by annotating actions on the AST.

http://www.graalvm.org/docs/graalvm-as-a-platform/implement-...

Here's an example of the addition operator from Graal's SimpleLanguage:

  @NodeInfo(shortName = "+")
  public abstract class SLAddNode extends SLBinaryNode {

      @Specialization(rewriteOn = ArithmeticException.class)
      protected long add(long left, long right) {
          return Math.addExact(left, right);
      }

      @Specialization
      @TruffleBoundary
      protected SLBigNumber add(SLBigNumber left, SLBigNumber right) {
          return new SLBigNumber(left.getValue().add(right.getValue()));
      }

      @Specialization(guards = "isString(left, right)")
      @TruffleBoundary
      protected String add(Object left, Object right) {
          return left.toString() + right.toString();
      }

      protected boolean isString(Object a, Object b) {
          return a instanceof String || b instanceof String;
      }
  }
https://github.com/graalvm/simplelanguage

By default it uses an arbitrary precision adder. But node rewriting on the AST (predicated by the "guard") provides specializations for long and String types. The long-type execution is a "fast path" that executes machine instructions directly; the String-type execution is a string concatenation.

A research paper provides further details:

https://dl.acm.org/citation.cfm?id=2658776

The full tutorial is at:

https://github.com/oracle/graal/blob/master/truffle/docs/Lan...

Re: GraalVM: Run Programs Faster Anywhere

#28
post #18

Earlier quoted context omitted.

Thanks! Out of curiosity — if I built an application with truffleruby, could I distribute it as a JAR (provided that it was run under JDK 9)? Are there ways to call out to Java like JRuby? Having some difficulty finding documentation around this.

> if I built an application with truffleruby, could I distribute it as a JAR Yes there is a Java embedding API. http://www.graalvm.org/docs/graalvm-as-a-platform/embed/ > (provided that it was run under JDK 9) It can run on 8. It'll be fast on JDK 9 or 10 because these have the interface to use Graal. > Are there ways to call out to Java like JRuby? JRuby compatible interop: https://github.com/oracle/truffleruby/blob…

Be warned, the jruby compatible interop isn’t complete, and I don’t have the jruby test suite running for it because that requires a much more complete implementation to run at all.

It’s good for quite a lot though.

Re: GraalVM: Run Programs Faster Anywhere

#29
post #18

Earlier quoted context omitted.

Thanks! Out of curiosity — if I built an application with truffleruby, could I distribute it as a JAR (provided that it was run under JDK 9)? Are there ways to call out to Java like JRuby? Having some difficulty finding documentation around this.

Yes you will be. But we use a different interface. Checkout this guide: http://www.graalvm.org/docs/reference-manual/polyglot/ Select your start and your target language and it will show you an example. Its a very basic example, but it basically works with all Java types. We will provide better docs soon.

We do have a partial implementation of the jruby API, though I don’t believe it works on substratevm due to reflection.
Post reply on HN