by yogthos · 1mo ago · 0 comments
Chez and produces native binaries with startup in the microsecond range and around 8 to 13 megs in size. That's not just slightly faster than JVM Clojure for cold starts. The JVM is designed around a model where you have a long-lived process like an app server. Even if you optimize Clojure's bootstrap down to zero, you're still hauling around a heavy runtime.
And GraalVM native-image comes with its own set of trade-offs since it's based on a closed-world assumption, which means dynamic class loading, reflection, serialization, and so on all need to be configured at build time. So, you can't do eval at runtime, and Babashka ends up having to use an interpreter for anything dynamic. Bytecode isn't available at runtime either, so you lose a bunch of the debugging and monitoring tools as well.
The compile time is also brutal. Last I tried making native-image it took several minutes to build, and you have to be careful with how you write code or what libraries you use. It's not just a different compile target that works as a drop in. There's a significant cost if you're iterating that quickly makes you miss the REPL.
So yeah, the JVM isn't the only reason Clojure starts slowly, but it's still a major contributing factor. Also, as I point out in the post, there are lots of negative connotations with JVM in the broader programming community. People have been preaching that the JVM is not a problem for years now, but it's still shunned. An perception is just as much a barrier as a technical limitation.
Jolt shows what's possible when you drop the JVM entirely.
In case you didn't actually look at the links, but the evidence seems to point to this not being true (JVM startup is ~10% of the time)
> you're still hauling around a heavy runtime
> around 8 to 13 megs in size
I think if you jpackage a Clojure app with no GUIs or anything (that then bundles only the strictly necessary parts of the JVM) - it's around 50MBs. It's still embarrassingly slow to launch, involves ugly installers, doesn't provide crosscompilation and the memory usage makes Electron apps look lean.
That's to say, I think Jolt has a very valid place in all of this :) If I could plug in Clojure code and get out small fast executables for all major OSs (cosmopolitan?) that I can then share, that'd be useful for the rare situation I don't have any JVM dependencies
And yeah, Jolt solved this problem for me completely. Startup is fast, you get a single binary, and it runs anywhere Chez Scheme runs which is mac, Linux, Windows, Android, and iOS. The best part is that you can use FFI to access native ecosystem as easily as Python.
There's also some fun Burin's been working on porting OpenLdk to Jolt https://github.com/jlt-commons/jolt-openldk
It might make it possible to translate Java bytecode to Jolt, and then link it into the binary similarly to native libs as a statically linked fasl. That way there might not even be much of a runtime cost.
and yeah, I dunno what's with Java apps being clunkers haha. I've come across games in Java that didn't feel bloated, but for some reason desktop apps almost always have a certain bloated feeling to them. Though I feel the same with Electron/VSCode (the input delay to me is very noticeable)
thank you for the work you do :)
Very much agree on Electron, there is a noticeable lag, and it's always bothered me that making a native app has become such a chore that people now just package a browser to render the UI.
And thanks, it's always nice to hear that it is useful and appreciated. :)