graalvm

Discuss GraalVM related topics. Use clojure 1.10.2 or newer for all new projects. Contribute to https://github.com/clj-easy/graal-docs and https://github.com/BrunoBonacci/graalvm-clojure. GraalVM slack: https://www.graalvm.org/slack-invitation/.
lread 2021-01-19T18:16:20.007900Z

Just got a notification for 21.0.0 release: https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-21.0.0

littleli 2021-01-19T18:22:46.008500Z

improved method handles support for native-image :hyper-clap:

borkdude 2021-01-19T18:33:38.008700Z

I am watching their live stream (link above)

borkdude 2021-01-19T18:39:20.008900Z

Wow, Java on Truffle: https://www.graalvm.org/reference-manual/java-on-truffle/

lukasz 2021-01-19T18:42:51.009600Z

cue in the "yo dog" Xzibit joke

borkdude 2021-01-19T18:51:45.009900Z

What this means: they implemented a Truffle interpreter for Java.

borkdude 2021-01-19T18:51:58.010300Z

This means you can now compile and run Java from source from within a native-image

borkdude 2021-01-19T18:52:13.010600Z

(not performantly yet, but they focused on compatibility first)

lread 2021-01-19T19:36:25.011600Z

Truffle can run bytecode too, I’ve never tried truffle. Does it have fast start up time?

borkdude 2021-01-19T19:40:16.011900Z

> Truffle can run bytecode too This is the new part, announced today.

borkdude 2021-01-19T19:40:48.012700Z

Truffle is a framework for creating interpreters that are self-optimizing. Languages implemented in Truffle can interop with each other.

borkdude 2021-01-19T19:41:01.013100Z

So you can have Ruby <-> Python interop if you use both Truffle implementations

borkdude 2021-01-19T19:41:11.013400Z

and a Truffle interpreter can be used inside a native-image

borkdude 2021-01-19T19:41:34.013900Z

So theoretically we can have the official JVM Clojure compiler, interpreted by Truffle Java, which runs inside a native-image.

borkdude 2021-01-19T19:41:41.014100Z

as of now.

lread 2021-01-19T20:00:39.014900Z

Very interesting!

mkvlr 2021-01-19T20:31:43.015700Z

@borkdude great stuff, did you play with it already?

borkdude 2021-01-19T20:32:18.015900Z

sorry, I'm quite lazy, not yet ;)

borkdude 2021-01-19T20:33:15.016800Z

I wonder if we can run the Clojure compiler from bytecode using Truffle Java in a native-image .. and what consequences this would have

mkvlr 2021-01-19T20:34:44.017700Z

yeah, same

mkvlr 2021-01-19T20:36:14.018500Z

does that make Clojure a truffle language now that Java is one?

borkdude 2021-01-19T20:36:57.019200Z

There is a thesis about a Clojure Truffle implementation from 2015 btw, but I don't think the source is public

mkvlr 2021-01-19T20:37:18.019600Z

it’s also pretty dated, I hear truffle came a long way since then

borkdude 2021-01-19T20:38:29.020700Z

I think having a proper Clojure on Truffle implementation would be faster than running the Clojure compiler through Java on Truffle, but I guess people should start experimenting with this

mkvlr 2021-01-19T20:40:02.021700Z

I want to play with this, but only after I’ve completed SICP, currently halfway in chapter 3

mkvlr 2021-01-19T20:43:40.022800Z

@eggsyntax did you ever get in touch with Thomas? I saw your tweet https://twitter.com/eggsyntax/status/992523127988121600

borkdude 2021-01-19T20:48:22.023600Z

Someone told me that sci is a meta-circular interpreter like written in SICP. I have SICP but I never really read it. Then I started in chapter 5 and omg, yes, this is more or less what it is ;)

eggsyntax 2021-01-19T20:56:38.024700Z

Unfortunately it looks like the link to the actual masters' thesis now goes to a one-page summary. I may still have a copy around if anyone wants to read it.

borkdude 2021-01-19T20:57:51.024900Z

The full PDF is here: https://epub.jku.at/obvulihs/download/pdf/501665?originalFilename=true

mkvlr 2021-01-19T21:10:31.029100Z

chapter 4 you mean right? https://sarabander.github.io/sicp/html/Chapter-4.xhtml#Chapter-4

mkvlr 2021-01-19T21:11:26.030100Z

two more sections in chapter 3 until I’m finally there…

borkdude 2021-01-19T21:12:10.031200Z

correct

littleli 2021-01-19T21:14:03.033600Z

I don't believe much there would be significant benefit to rewrite Clojure as Truffle language. Maybe like 20-25% max at peak. Clojure compiler produces already quite effective code. I don't have numbers, but as a former Oracle Labs employee I had some very interesting discussion with Graal/Truffle people in the kitchen :-)

littleli 2021-01-19T21:16:23.037300Z

Of course Clojure compiled to Java bytecode can already benefit from improved escape analysis and other goodies offered by GraalVM bytecode interpreter.

borkdude 2021-01-19T21:16:27.037400Z

@ales.najmann The fun thing about Truffle languages is that they can also be compiled along in a native-image.

borkdude 2021-01-19T21:16:50.037900Z

or I should say, one fun thing

littleli 2021-01-19T21:16:57.038400Z

Yes and they are more natural fit of course

borkdude 2021-01-19T21:17:13.038900Z

another fun thing is polyglot: one could reach Clojure programs from other languages like Python (not that I'm personally interested in this)

mkvlr 2021-01-19T21:17:21.039100Z

@borkdude but isn’t that also true for Clojure in Java now?

mkvlr 2021-01-19T21:17:41.039600Z

compiling along I mean

borkdude 2021-01-19T21:17:45.039800Z

well, I mean, eval would then "just work" and that doesn't right now

phronmophobic 2021-01-19T21:24:13.046Z

it will be interesting if any of these avenues opens up an opportunity for clojure to run well on mobile. I now cljs can be used for mobile apps, but I think a compiled or sufficiently efficient intrepreter would be really cool.

borkdude 2021-01-19T21:26:10.048500Z

In that area, this could also be interesting: https://twitter.com/cgrand/status/1350063059864346624

borkdude 2021-01-19T21:27:15.049100Z

I have never tried to do mobile with graalvm, or really anything, but I've heard people make apps with it and deploy them to the app store. I think you could do this without truffle though and just write Clojure bindings for the appropriate framework e.g. JavaFX

borkdude 2021-01-19T21:27:28.049300Z

which already exist

borkdude 2021-01-19T21:28:17.049500Z

https://gluonhq.com/products/mobile/

phronmophobic 2021-01-19T21:29:00.049800Z

lots of exciting stuff. it's potentially already possible, but I haven't had a chance to try the options

phronmophobic 2021-01-19T21:30:53.050Z

I have my own platform agnostic UI library that is graalvm compatible. at some point I'd like to try and compile and link it to iOS/android skia libs for making mobile apps with clojure, but I'm not sure what all the obstacles might be

borkdude 2021-01-19T21:31:48.050300Z

@smith.adriane Ah, that's the one which also supports lanterna right?

borkdude 2021-01-19T21:32:21.050900Z

We have tried upgrading lanterna to 3.0 for the clojure-lanterna lib here: https://github.com/babashka/clojure-lanterna

phronmophobic 2021-01-19T21:32:27.051500Z

yep, and skia, skija, javafx, swing, and webgl!

phronmophobic 2021-01-19T21:33:49.052200Z

ideally, it would be great to be able to mix and match (re-frame, fulcro, reagent, etc) with platform (terminal, desktop, web, and mobile, etc)