I've given it a lot of thought if cream (based on Crema, a native-image compatible byte-code interpreter, basically a JVM inside of native-image) should affect babashka.
https://github.com/borkdude/cream
What it concretely would mean to move babashka to crema is that we could run virtually any Clojure program without changes. But it has serious downsides compared to using SCI.
Mainly: load time of clojure sources. E.g. in bb+SCI, loading malli from source costs 60ms, but in cream it takes 1300ms. Evaluating a fn emits a class which just takes more work. But bb+SCI is just way faster for loading bigger libraries from source and then executing some expressions, which is commonly called "scripting". When loading a bigger lib like malli, you might as well just use a normal JVM instead of cream. Performance of cream is better than bb (for hot JIT-ed code), but worse than a JVM.
Since the core feature of bb is scripting with good startup time, bb + SCI wins here,
Another major downside of including crema is that the binary size goes up from 75 -> 225mb. Maybe this isn't that important, but compile times also double or triple which isn't fun at all when you build a binary in CI for several OSes. SCI is just way more light weight.
For a while I thought SCI would be replaced with crema in bb, but it still wins for the scripting.
You can view some of the numbers here: https://github.com/borkdude/cream#cream-vs-babashka
Just FYI!
babashka sci
blogged in more detail here: https://clojurians.slack.com/archives/C8NUSGWG6/p1793627342952799
I don't much about graal, and while I have been a happy bb user for ages, my mental model of its implementation is pretty minimal. But naive me wonders if the two approaches could be smashed together? I'm imagining a bb that is sci + core standard lib + native image + crema. Clojure continues to be interpreted via SCI, but interop happens in graal + crema land. You no longer have to choose what java classes / libraries to bake in: "baking in" a library means running bb with a flag that pulls in the underlying libraries and caches them to disk. bb remains fast-starting, interpreted clojure oriented toward scripting. But crema lets you generalize interop, so that you no longer need to decide what goes in bb's standard library and what does not.
Haha I was about to type in a similar naive question:sweat_smile: Naive minds think alike or something
This is obviously a user's perspective without any understanding of what it would take to get there, I'm not even sure if the semantics would make sense.
I have also investigated something that. Let me add a paragraph to my blog post
Another naive thought, maybe cream can be exposed via a babashka.pod. A bit similar to what I tried to do here https://github.com/jeroenvandijk/pod-babashka-clj (this starts an actual jvm process so cream would be the same, but faster boottime guess)
updated
Cool that makes sense, thanks for updating!
Another naive idea, can a babashka process be "upgraded" (re-run with Cream) when the analyzer finds unknown classes and retry? This upgrading could be optional via a system setting (to keep small binaries for instance). I'm guessing one problem is that a script can have already executed some side effects before the upgrade part of the program is discovered
@borkdude it is great that you are working on all the alternatives runtimes, thank you very much. They solve two of the biggest problems of the JVM nowadays: cold-start time and the high memory consumption. Since people are letting AI rewrite everything in Rust nowadays (like the whole TypeScript compiler), I am always triggered and think: hey lets rewrite the JVM in Rust 😄 Then run normal Clojure on top of it with fast cold-start and low memory consumption. I think Crema from GraalVM is a step into this direction as well, but maybe Oracle will always make it too complex. Maybe it is time to vibe-code a lightweight JVM 😅 Just my 2 cents
@maxweber I think the rewrite the JVM direction is being tried with things like Jolt and Glojure. They also show that this is quite complicated as many clojure libraries use the Java APIs. One of the reasons why Graal is so powerful is because the Java APIs just work as expected out of the box