Here's example project with Clojure running in WASM with graal 25 native-image's wasm backend https://github.com/roman01la/graal-clojure-wasm
To ask a naive question: Why not over the GraalJS implementation?
@shalokshalom this is doable for a while without many extra steps Roman was exploring/experimenting the new graalvm features of jar2wasn
5MB output is quite big but who cares π
it's possible to shave off like 400KB with wasm-opt https://github.com/WebAssembly/binaryen?tab=readme-ov-file#wasm-opt but that required enabling some wasm runtime flags
is this 5MB for hello world?
yep
can it do eval? ;)
lemme run a web server... π
clojure -A:native-image should be -M:native-image
Error: 'wasm-as' not found on the system path. Please extend the PATH environment variable so that it provides a Wasm assembler executable called 'wasm-as'.
I guess this needs to be documentedno idea what's that
probably you already had it installed
maybe you need to create a new terminal session after installing stuff
installing what stuff?
everything mentioned in the readme
I installed sdk and I'm using the graalvm eap
nothing else is mentioned?
ah ok I thought the other thing was optional but it's not, ok, you also need brew install binaryen
well eval doesn't work
I suspected it. But SCI will maybe work (like in native-image). I'll give it a shot. What benefits does running Clojure code in WASM have, interop with other JavaScript stuff?
and what are the limitations, can you use the entire Java stdlib?
don't know, it's just fun to see it's possible
alright, it's compiling!
$ time node core.js
Hello, World!
node core.js 0,16s user 0,03s system 109% cpu 0,169 totalnow let's try to add some evaluation π
now if SCI works you can embed it into a web page as a demo
oh that would be exciting
Try JVM Clojure in the browser via SCI... hm
error:
Fatal error: jdk.graal.compiler.debug.GraalError: com.oracle.svm.core.util.VMError$HostedError: The following method is reachable during compilation, but was not seen during Bytecode parsing: sun.nio.fs.BsdFileSystem.directCopy0(int, int, long)
at method: int sun.nio.fs.BsdFileSystem.directCopy0(int, int, long) [Direct call from void UnixFileSystem.copyFile(UnixPath, UnixFileAttributes, UnixPath, UnixFileSystem$Flags, long)]Caused by: com.oracle.svm.core.util.VMError$HostedError: The following method is reachable during compilation, but was not seen during Bytecode parsing: sun.nio.fs.BsdFileSystem.directCopy0(int, int, long)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:78)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:137)
at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.guarantee(VMError.java:146)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.code.CompileQueue.defaultCompileFunction(CompileQueue.java:1256)
... 12 moreI guess this is where the experiment ends for now ;)
looks like threading model is not supported either, well it's a good start at least
indeed
if you discuss these problems in the GraalvM Slack community you usually get good replies.
What are implications of this? which types of application could benefit from this?
running spring boot apps in a browser
so kinda solves distribution problem, maybe
re missing pieces https://github.com/graalvm/graalvm-demos/issues/346#issuecomment-2774867010
I don't know why it's complaining about some file system thing in SCI. AFAIK SCI doesn't use any file system stuff
mind sharing the output?
wait, it could be the result of --initialize-at-build-time - you should limit this as much as possible.
this is why we made: https://github.com/clj-easy/graal-build-time
I'll try with that
alas
output: https://gist.github.com/borkdude/a06b7fb3489472e65b21dc7a52eba50c
chatgpt has some good pointers https://chatgpt.com/share/680b6cc6-c4ac-800a-bba0-330ba2ea7a0e
I think at this point it's better to talk to a person who really know stuff than randomly trying shit :)
BUT AREN'T YOU ARE AN EXPLORER????
π
I actually know the stuff that chatgpt suggested, but some of these flags are already the default
but yeah, vibe coding right? ;)
that is the way, looking forward to make a fortune by fixing llm generated code
I misread fortune as torture ;)
Ah, ok. And between Espresso, GraalJS and WASM, what is the most supported at the current time? Particularly in consideration towards interacting with other Truffle languages.
Probably the GraalVM Slack community is the best place to ask since the Graal teams hangs out over there
> I misread fortune as torture π ΒΏPorque no los dos? laughcry