[HN Gopher] Ribbit Scheme bootstraps with Posix shell while supp... ___________________________________________________________________ Ribbit Scheme bootstraps with Posix shell while supporting TCO, call/cc and GC Author : feeley Score : 32 points Date : 2022-04-20 13:39 UTC (2 days ago) (HTM) web link (github.com) (TXT) w3m dump (github.com) | chongli wrote: | I hate to be pedantic here but I see the term TCO thrown around | all the time. The Scheme standard requires that unbounded tail | call functions can run in constant space. | | This is a semantic difference, not an optimization. Turning off | optimizations should never cause your program to crash. | feeley wrote: | I wrote TCO in the title because with "proper tail calls" the | title exceeded the allowed limit on hacker news! Moreover most | people will know the term TCO and less the more precise term | proper tail calls. You are of course correct that tail calls | are a required aspect of the Scheme specification even though | many implementations that call themselves "Scheme" don't | implement this fully. | paines wrote: | I am not sure if I understand correctly. So this is a scheme | running on a scheme. You need e.g. Chicken to compile/minify it | and then run it via Gambit.... Why? Why would I do, except of | learning puroposes of course, do such thing. I clearly am missing | something. | feeley wrote: | You need a Scheme interpreter (Gambit, Chicken or Guile have | been tested) to run the Ribbit AOT compiler. The Ribbit AOT | compiler will compile a Scheme program to one of the supported | target languages: C, JavaScript, Python, Scheme or POSIX shell | script. Ribbit has been designed for a small footprint, so the | generated target code is quite compact (as small as 2-4 KB for | small programs). This is much more compact than any other | existing Scheme system. Moreover the system is very portable to | other target languages because Ribbit is implemented with a | tiny virtual machine. There are ports underway to Java, Scala, | Lua, Rust, go, Ruby, Haskell, and Idriss. This means a larger | program in any of these languages can embed the Ribbit VM for | scripting or other purposes. | | Ribbit is also bootstrapped (it can compile itself). This means | that you only need another Scheme system for the initial step | of the bootstrap to compile the Ribbit compiler to one of the | supported target languages. After this step the Ribbit compiler | only needs an implementation of the target language to run. For | example, you can use the Gambit interpreter to compile the | Ribbit compiler to a POSIX shell script (about 64K bytes). | After this is done then you only need a POSIX shell to compile | any Scheme program to C, JavaScript, Python, or POSIX shell | script. | | In its current state the POSIX shell target is mostly a proof | of concept to demonstrate that the Ribbit VM is extremely | portable. One area of practical use is for bootstrapping | compilers for other languages using minimal tools (see the Mes | project https://bootstrappable.org/projects/mes.html for | bootstrapping gcc to have a reproducible build process for | gcc). With Ribbit's POSIX shell target it would be possible to | build gcc on any system that has a POSIX shell (without needing | other build tools like a C compiler, linker, etc). | paines wrote: | Thank you very much for the detailed explanation! ___________________________________________________________________ (page generated 2022-04-22 23:01 UTC)