Story Details

  • Running Clojure in WASM with GraalVM

    Posted: 2025-04-27 07:50:07

    This blog post details the author's successful experiment running Clojure code in a web browser using WebAssembly (WASM) compiled via GraalVM Native Image. The process involves using SCI, the self-hosted Clojure interpreter, to create a native image ahead-of-time (AOT) that can be further compiled to WASM. The post highlights several key steps, including preparing a minimal Clojure project, utilizing GraalVM's native-image tool with necessary configuration for WASM, and finally embedding the resulting WASM file in a simple HTML page for browser execution. The author showcases a basic "Hello, World!" example and briefly touches on potential benefits like performance improvements, albeit acknowledging the current limitations and experimental nature of the approach.

    Summary of Comments ( 29 )
    https://news.ycombinator.com/item?id=43810211

    Hacker News users discussed the challenges and potential benefits of running Clojure in WASM using GraalVM. Several commenters pointed out the substantial resulting file sizes, questioning the practicality for web applications. Performance concerns were also raised, particularly regarding startup time. Some suggested exploring alternative approaches like using smaller ClojureScript compilers or different WASM runtimes. Others expressed excitement about the possibilities, mentioning potential applications in serverless functions and plugin systems. One commenter highlighted the contrast between the "write once, run anywhere" promise of Java (which GraalVM leverages) and the current state of browser compatibility issues. The overall sentiment leaned towards cautious optimism, acknowledging the technical hurdles while recognizing the potential of Clojure in the WASM ecosystem.