[HN Gopher] Directly compiling Scheme to WebAssembly: lambdas, r...
       ___________________________________________________________________
        
       Directly compiling Scheme to WebAssembly: lambdas, recursion,
       iteration
        
       Author : rekado
       Score  : 107 points
       Date   : 2023-05-31 08:20 UTC (14 hours ago)
        
 (HTM) web link (spritely.institute)
 (TXT) w3m dump (spritely.institute)
        
       | schemescape wrote:
       | Tangential question: How interoperable are the top Scheme
       | implementations (Guile. Chez, Chicken, etc.)? Specifically, are
       | libraries (beyond SRFIs) often supported in multiple
       | implementations?
        
         | tgbugs wrote:
         | It will depend on which implementation specific behavior a
         | given library uses. For example, guile has `#{}#` syntax for
         | verbatim atoms. If a library uses that it will not work on any
         | other scheme. Guile and gambit also have divergent behavior
         | when e.g. parsing char literals `#\\)a` parses correctly in
         | guile but not gambit, and on the other hand `'a'b'c` reads as
         | `c` in gambit but `a'b'c` in guile. And these are just issues
         | with variant behavior in the reader.
         | 
         | The list of these kinds of edge cases is long so it probably
         | winds up being easier to try to just run a library to see if it
         | works. I doubt anyone has done a systematic survey.
        
         | jhoechtl wrote:
         | Bumping. Would be deeply interested too.
         | 
         | I did some search and didn't find any recent statement on that.
        
         | tmtvl wrote:
         | There are some that run on generic R[67]RS, but many libraries
         | tend to target a specific implementation (chicken with its
         | eggs, all the guile-whatever libraries). You can check out Akku
         | (akkuscm.org) or Snow for Scheme-oriented package managers.
        
       | dontlaugh wrote:
       | As soon as I saw WAT I've wondered whether a series of
       | transformations from a Scheme would end up efficient. I'm glad
       | someone proved it.
        
       | zelphirkalt wrote:
       | It is worth checking out other stuff that has come out of
       | spritely institute as well:
       | 
       | There was something about a distributed debugger [1]. Also look
       | at a talk about Goblins itself [2].
       | 
       | [1]: https://spritely.institute/news/introducing-a-distributed-
       | de...
       | 
       | [2]: https://invidious.baczek.me/watch?v=VyTlQ0zwIAM
       | (VyTlQ0zwIAM)
        
       | abrax3141 wrote:
       | Ahhhh! A breath of fresh air in this world of ugly Algol-wedged
       | hyper-utilitarianism. (I was going to say "hyper-functionalism",
       | but the unintended pun confused the sense.) [Although, I must
       | admit that js is actually pretty descent, and can almost be used
       | like Lisp if you look at it hard enough and cross-eyed.]
        
         | xigoi wrote:
         | JavaScript was originally meant to be a Scheme dialect, but
         | corporate people wanted it to look more like Java.
        
       | beepbooptheory wrote:
       | All day I push out js for a paycheck, all night I live and tinker
       | in my Lisp/scheme worlds. Maybe one day these will be overlayed.
        
         | davexunit wrote:
         | I did fairly standard web dev and devops for 10 years before
         | finding work at a Lispy place. Best of luck to you!!
        
         | kaba0 wrote:
         | ClojureScript? I hear it is a really great guest language that
         | fits within its respective host ecosystem very nicely (though I
         | have mostly used it on the JVM), but the underlying library
         | that converts it to JS is very battle-tested and produces great
         | code!
        
         | Turing_Machine wrote:
         | This project is very exciting. In the meantime, there are a
         | couple of options:
         | 
         | BiwaScheme: https://www.biwascheme.org/
         | 
         | Advantages: written in JavaScript, with excellent JS interop.
         | Project has some history.
         | 
         | Disadvantages: slower than S7 (though still plenty fast for
         | many uses), less-complete (e.g., no syntax-rules or syntax-
         | case, though it does have its own define-macro).
         | 
         | S7 Scheme: https://cm-gitlab.stanford.edu/bil/s7
         | 
         | Written in C, but can be transpiled to WASM (see
         | https://github.com/actonDev/s7-playground/ )
         | 
         | Advantages: This project also has some history. Considerably
         | faster than BiwaScheme.
         | 
         | Disadvantages: JS interop is clumsier (basically the same
         | issues as JS interop with any WASM code... this could probably
         | be mitigated considerably if someone wanted to take the time).
        
         | bitwize wrote:
         | Gambit has a JavaScript compilation target backend. It works
         | really well. The runtime code you need to run JS-compiled
         | Gambit code is large, but compared to the neutron-star density
         | of most projects' node_modules it's utterly manageable. It's a
         | little harder to justify on the front end though.
        
       | dreamcompiler wrote:
       | Last I checked WASM did not yet allow tail jumps. Without these
       | compiling Scheme would be very clumsy. Has this been resolved?
        
         | paroneayea wrote:
         | It's being supported in an extension that looks on track to be
         | broadly available across WASM runtimes soonish.
        
         | agency wrote:
         | The proposal was recently bumped to stage 4 (the penultimate
         | stage) with at least a couple of runtimes working on
         | implementing (besides v8, which has supported it for quite
         | awhile now)
         | 
         | https://github.com/WebAssembly/proposals
        
       | neilv wrote:
       | This is very promising. Years ago, I was thinking that probably
       | Racket, Gambit, or someone's dissertation would evolve into
       | production-grade Wasm target. But looks like Andy Wingo, et al.,
       | are really tackling it through Guile.
        
         | gmatejka wrote:
         | I built rasm (https://github.com/GrantMatejka/rasm) to compile
         | racket to wasm. Definitely not production grade, but fun
         | nonetheless
        
           | neilv wrote:
           | Projects like these are great, and absolutely in traditions
           | of Scheme, PL research, hobbies/learning, and sometimes
           | startups.
           | 
           | Not everything has to be overtly adopted to be worth doing.
           | 
           | Historically, when someone makes some advancement that
           | doesn't lead to adoption, it seems often because:
           | 
           | * there's no follow-through to production-grade (maybe the
           | norm with PL dissertations, if the next job isn't industry
           | and directly involving that same platform);
           | 
           | * the market applicability is too niche/nonexistent, at least
           | at the time (e.g., someday people will realize better DSLs
           | were figured out a long time ago); or
           | 
           | * didn't promote it well enough.
        
       | Conscat wrote:
       | https://github.com/google/schism
       | 
       | For some reason, Google was working on a Scheme WASM compiler,
       | which they got self-hosting. It was then abandoned. I don't
       | really know what they were trying to accomplish with that
       | project.
        
         | sitkack wrote:
         | This was a personal project of a then-Googler, not a Google
         | project.
         | 
         | https://github.com/schism-lang/schism
         | 
         | Previous discussion with comments by the author,
         | https://news.ycombinator.com/item?id=16488605
        
       ___________________________________________________________________
       (page generated 2023-05-31 23:01 UTC)