by wink · 8y ago · 0 comments
So if you're using Clojure and Leiningen and are annoyed by the long startup times... there's potential :)
Performance can vary quite a lot from task to task, also compile times suffer a lot and you lose some dynamic features.
So from what I understand it might be useful for clojure cli apps, but at this point I am not sure it brings a lot, but this is early days.
The cool part is the polyglot capabilities imho.
Then there's the elephant in the room: the licensing and potential changes in the long run.
For clojure if you want decent cli/startup experience there's always cljs, lumo or you can go with something like fennel-lang, a clojure looking lisp that "transpiles" to lua(jit), so 0 overhead compared to lua and super fast startup.
That's actually really bad in Graal. I compiled a few classes project in Java, JS and Ruby. Compilation time was measured in minutes and memory usage most of the time was >8GB.
SubstrateVM was designed more to make Graal/Truffle based interpreters like TruffleRuby and FastR have fast startup time with small binaries, which is a large and complex project, more than it was meant to compile small, random one-off Java/JVM applications for CLI usage. From what I remember in my few random experiments the compile time isn't quite linear in size at least (e.g. compiling a 10 line Java class file takes 2 minutes, but compiling a 100 line one takes only marginally longer, comparatively.)
(Using SubstrateVM also means that there is no JIT for the JVM class files you compile to native code, so you're dealing with a purely ahead-of-time compilation scheme. Graal's online JIT still kicks in for SubstrateVM-based interpreters like TruffleRuby, however. This is an important distinction to understand.)
Hopefully they can improve the compile time requirements a bit for cases like this, since it's surely more popular and common case that people are looking for, as opposed to writing Truffle-based interpreters.
For general CLI tools, yes, I'd also look into cljs at this time.
edit: a bit more on zprint & GraalVM and a comparison to the equivalent code on node:
graalVM native startup time: 0.055s
node startup time: 0.260s
execution time is also more than 1 order of magnitude faster w/ graalVM native compared to nodehttps://github.com/kkinnear/zprint/blob/master/doc/graalvm.m...
With tools.deps and the need of some companies for more advanced build setup a lot of people are actually thinking about these issues.
But I'd be surprised indeed, I'm not watching the whole clojure space closely, I can only say that no one hit the #leiningen irc channel or posted something on the bugtracker/proposed a PR yet.
And the client/server model.. sure, nailgun and grenchman were a bit clunky, but none of these efforts have gained widespread adoption, afaik. Most people don't just go out of their way to tweak their build tool.
> So you have no excuses not to build your CLI tools in Clojure now.
Well I do disagree with this part, see other sibling comments (not by me). I'm not even sure GraalVM is really production-ready, notwithstanding the potential licensing and long-term issues.
I do agree it's at least worth trying.
The big minefield is that you do not really know which libraries will go boom and where, as any place could make use of class loading.
One main problem I also see is the distribution. Currently leiningen only needs "some sort of java executable" and then the rest is pulled in. So would you have to have GraalVM installed or could this also be bootstrapped.