graalvm

Roman Liutikov 2025-04-25T10:14:50.293109Z

Here's example project with Clojure running in WASM with graal 25 native-image's wasm backend https://github.com/roman01la/graal-clojure-wasm

3
πŸŽ‰ 9
Matthias Schuster 2025-05-20T12:39:10.831819Z

To ask a naive question: Why not over the GraalJS implementation?

souenzzo 2025-05-21T10:49:51.182609Z

@shalokshalom this is doable for a while without many extra steps Roman was exploring/experimenting the new graalvm features of jar2wasn

Roman Liutikov 2025-04-25T10:16:03.528789Z

5MB output is quite big but who cares πŸ˜„

Roman Liutikov 2025-04-25T10:17:24.672359Z

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

borkdude 2025-04-25T10:18:12.022729Z

is this 5MB for hello world?

Roman Liutikov 2025-04-25T10:18:31.228019Z

yep

borkdude 2025-04-25T10:18:48.664449Z

can it do eval? ;)

😁 1
Roman Liutikov 2025-04-25T10:18:56.848609Z

lemme run a web server... πŸ˜„

borkdude 2025-04-25T10:20:41.524849Z

clojure -A:native-image should be -M:native-image

borkdude 2025-04-25T10:21:30.857019Z

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 documented

Roman Liutikov 2025-04-25T10:21:54.992459Z

no idea what's that

borkdude 2025-04-25T10:22:16.860749Z

probably you already had it installed

Roman Liutikov 2025-04-25T10:22:48.402219Z

maybe you need to create a new terminal session after installing stuff

borkdude 2025-04-25T10:23:03.566689Z

installing what stuff?

Roman Liutikov 2025-04-25T10:23:24.697289Z

everything mentioned in the readme

borkdude 2025-04-25T10:23:55.699939Z

I installed sdk and I'm using the graalvm eap

borkdude 2025-04-25T10:24:00.527799Z

nothing else is mentioned?

Roman Liutikov 2025-04-25T10:24:19.821929Z

ah ok I thought the other thing was optional but it's not, ok, you also need brew install binaryen

πŸ‘ 1
Roman Liutikov 2025-04-25T10:26:48.781689Z

well eval doesn't work

borkdude 2025-04-25T10:28:12.375039Z

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?

borkdude 2025-04-25T10:28:39.165649Z

and what are the limitations, can you use the entire Java stdlib?

Roman Liutikov 2025-04-25T10:28:48.521439Z

don't know, it's just fun to see it's possible

πŸ‘ 1
borkdude 2025-04-25T10:33:23.002369Z

alright, it's compiling!

borkdude 2025-04-25T10:34:44.968769Z

$ time node core.js
Hello, World!
node core.js   0,16s  user 0,03s system 109% cpu 0,169 total

3
borkdude 2025-04-25T10:35:27.933979Z

now let's try to add some evaluation 😁

Roman Liutikov 2025-04-25T10:35:40.852719Z

now if SCI works you can embed it into a web page as a demo

borkdude 2025-04-25T10:36:41.957589Z

oh that would be exciting

borkdude 2025-04-25T10:37:00.824559Z

Try JVM Clojure in the browser via SCI... hm

borkdude 2025-04-25T10:37:16.962959Z

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)]

borkdude 2025-04-25T10:37:58.727409Z

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 more

borkdude 2025-04-25T10:38:10.302929Z

I guess this is where the experiment ends for now ;)

Roman Liutikov 2025-04-25T10:48:21.823589Z

looks like threading model is not supported either, well it's a good start at least

borkdude 2025-04-25T10:49:16.521789Z

indeed

borkdude 2025-04-25T10:49:42.538579Z

if you discuss these problems in the GraalvM Slack community you usually get good replies.

πŸ‘€ 1
siavash mohammady 2025-04-25T10:53:05.356129Z

What are implications of this? which types of application could benefit from this?

Roman Liutikov 2025-04-25T10:53:58.796229Z

running spring boot apps in a browser

Roman Liutikov 2025-04-25T10:54:12.811809Z

so kinda solves distribution problem, maybe

πŸ‘ 1
Roman Liutikov 2025-04-25T10:58:05.518229Z

re missing pieces https://github.com/graalvm/graalvm-demos/issues/346#issuecomment-2774867010

πŸ‘ 1
borkdude 2025-04-25T10:59:16.329849Z

I don't know why it's complaining about some file system thing in SCI. AFAIK SCI doesn't use any file system stuff

Roman Liutikov 2025-04-25T10:59:34.591679Z

mind sharing the output?

borkdude 2025-04-25T11:00:40.438929Z

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

πŸ‘€ 1
borkdude 2025-04-25T11:00:44.210749Z

I'll try with that

borkdude 2025-04-25T11:03:11.846799Z

alas

borkdude 2025-04-25T11:04:03.494369Z

output: https://gist.github.com/borkdude/a06b7fb3489472e65b21dc7a52eba50c

Roman Liutikov 2025-04-25T11:07:04.253079Z

chatgpt has some good pointers https://chatgpt.com/share/680b6cc6-c4ac-800a-bba0-330ba2ea7a0e

borkdude 2025-04-25T11:09:53.407049Z

I think at this point it's better to talk to a person who really know stuff than randomly trying shit :)

Roman Liutikov 2025-04-25T11:12:12.389259Z

BUT AREN'T YOU ARE AN EXPLORER????

Roman Liutikov 2025-04-25T11:12:13.462689Z

πŸ˜„

borkdude 2025-04-25T11:12:56.932999Z

I actually know the stuff that chatgpt suggested, but some of these flags are already the default

πŸ‘ 1
borkdude 2025-04-25T11:13:24.907809Z

but yeah, vibe coding right? ;)

Roman Liutikov 2025-04-25T11:23:25.929789Z

that is the way, looking forward to make a fortune by fixing llm generated code

borkdude 2025-04-25T12:10:06.265619Z

I misread fortune as torture ;)

πŸ˜‚ 3
Matthias Schuster 2025-05-22T12:23:17.506169Z

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.

borkdude 2025-05-22T12:27:38.665289Z

Probably the GraalVM Slack community is the best place to ask since the Graal teams hangs out over there

mauricio.szabo 2025-04-29T01:51:28.827439Z

> I misread fortune as torture πŸ˜‰ ΒΏPorque no los dos? laughcry