[HN Gopher] Scm2wasm: A Scheme to WASM compiler in 600 lines of ...
       ___________________________________________________________________
        
       Scm2wasm: A Scheme to WASM compiler in 600 lines of C, making use
       of WASM GC
        
       Author : todsacerdoti
       Score  : 115 points
       Date   : 2025-09-28 15:43 UTC (7 hours ago)
        
 (HTM) web link (git.lain.faith)
 (TXT) w3m dump (git.lain.faith)
        
       | koolala wrote:
       | Can it be used as a interpreter once compiled to not need a
       | compiler?
        
         | wk_end wrote:
         | Just eyeballing it really quickly, it doesn't look like it's
         | got the built-ins you'd want to quickly built a REPL (i.e. read
         | or eval). It's not really Scheme, yet.
         | 
         | It's written in C, so you could compile that to wasm and then
         | compile & run all inside the browser (I guess, assuming wasm is
         | cool with that sort of thing, not a wasm guy here).
        
           | circuit10 wrote:
           | You can do that kind of JIT code generation with WASM but you
           | need to compile a separate module and load and link things up
           | in JS (doable but not technically within pure WASM, so it
           | won't work in standalone runtimes)
        
         | shakna wrote:
         | This isn't quite a standards conforming Scheme just yet.
         | 
         | On the other hand, Hoot supports WASM-GC on release [0], and
         | has had wasm support for a few years now. (Though Safari
         | support has been a pain point - they've found a few bugs in
         | WebKit's wasm support.)
         | 
         | [0] https://spritely.institute/news/hoot-0-6-1-released.html
        
       | sshine wrote:
       | Related: Guile Hoot is a Scheme to Wasm compiler written in
       | Scheme.
       | 
       | https://spritely.institute/hoot/
        
       | marianoguerra wrote:
       | In case you are interested I wrote a minimal OOP runtime in wasm-
       | gc (using wasm text format) here:
       | https://marianoguerra.org/posts/bootstrap-post-collapse-oop-...
       | 
       | I also wrote a forth in wasm by hand here:
       | https://github.com/marianoguerra/ricardo-forth
       | 
       | And a wasm compiler that fits in a tweet:
       | https://wasmgroundup.com/blog/wasm-compiler-in-a-tweet/
       | 
       | I'm also the co-author of a book that shows you how to write a
       | compiler that targets wasm for a small languaje using js:
       | https://wasmgroundup.com/
       | 
       | Here's a direct link to the wasm text format for the OOP and
       | forth implementations:
       | 
       | - https://github.com/marianoguerra/mclulang/blob/main/wat/fatt...
       | 
       | - https://github.com/marianoguerra/ricardo-forth/blob/master/s...
        
       | nakamoto_damacy wrote:
       | With call/cc ??
        
       ___________________________________________________________________
       (page generated 2025-09-28 23:00 UTC)