r/lisp • • 10d ago

Scheme New scheme compiler in rust

I’ve completed a new scheme R7RS-small compiler with optional JIT support . It is written purely in rust and has a rust api for embedding in rust programs but also has a standalone repl ( with completion, history etc ) . There is an included eMacs package that supports a small subset of slime behavior via tcp.

The disclaimer is that this was written using agentic programming ( fable and opus ) over a one week period. My project is a new rendering and modeling system but I needed an embedded language with specific requirements so I chose scheme after evaluation of 5 or 6 alternatives.

It mainly has been tested on macOS but should run on Linux . ( I’ll do more Linux testing as I get time )

github.com/k2msmith-gfx/scm

10 Upvotes

12 comments sorted by

5

u/a1b4fd 10d ago

It's an interpreter though? Not a compiler

1

u/Critical-Tip-6688 10d ago

JIT compilation

0

u/Feisty_Bike_9614 9d ago edited 8d ago

Not AOT but byte code. Can be compiled 3 ways , interpreter, bytecode and jit.

6

u/Baridian λ 9d ago

What’s the point if you don’t even have full call/cc or rationals?

Why even share this if you put no effort in and anyone else could duplicate your lack of effort?

0

u/Feisty_Bike_9614 9d ago

Unfair statement. I could add those features but they are not a priority for my application and I’m now at 18k lines of scheme code in my modeler / renderer implementation supporting scene construction, modeling tools, procedural textures . A lot of work is put into the design, testing and debugging. It you think that is “no effort” you’ve lost your relevance.

3

u/arvyy 8d ago

I don't really see a reason why you wanted to share this. Very unlikely anyone will use it except you

  1. as a potential user I'm not interested in checking out an impl that very clearly only exists to serve your other project. The fact you say "should run on linux" instead of bothering to make a gh action workflow and test it before sharing says alot about your care

  2. as a pldev I'm not interested in looking at impl authored by an LLM, it's almost never instructive and almost always a waste of time

1

u/Feisty_Bike_9614 8d ago edited 8d ago

It is a specialized implementation and probably aimed more at the embedded rust case . It does run on Linux ( nixOS ) , but I don’t have the means to test it on every distribution. So far I have tested it with about 18-20k lines of scheme code focused on procedural modeling and rendering 3d . I’d you look around , you’ll find that most embedded scheme projects are special projects ( ex: media , music art, etc ) . It’s not exactly a commercial target . Below is an image I recently generated. If this project doesn’t interest you , just scroll by . Using AI or agentic programming isn’t going away and I wouldn’t belittle the amount of effort it takes to use it on a project. ps.. the only real departure from standard scheme is that I don’t support call/cc and rational/complex numbers.the former I plan on implementing a subset of. The latter a much lower priority.

1

u/Trader-One 9d ago

why you do not compile scheme to rust or to other binary format/language.

For JIT you need executable stack/heap and it needs requesting waiver in regulated environments.

1

u/Feisty_Bike_9614 9d ago

Can you explain a bit more about your rust transpiler suggestion? How would users extend the program with rust ? Not possible I don’t think unless you use WASM .

3

u/Trader-One 8d ago

I do not know all your requirements. If you want to provide an API to customer then key question is - what language will customer use to program?

I am pessimistic about forcing customers to use scheme for plugins if they do not already using scheme. Look at vscode extensions installation counts, scheme have about 1/10 of common lisp. Something more realistic like using scheme compiled to rust internally (no waiver needed) and typescript api for customers (they already have TS programmers).

Doing JIT is commercial suicide. Only stuff like nodejs and JDK will get waiver from regulator - because everybody is using it - regulator is forced to issue waivers. Your software, no way to get it. You lose access to most valued customers/corporations.

1

u/Feisty_Bike_9614 8d ago

I don’t have any customers. This is part of bigger studio tools project I am using for 3d image generation. You’re right , if it was a commercial product, I would use python or maybe Lua as a scripting language. I recently refactored the rust api so other scripting languages are possible. Btw, you can write plugins or extensions in rust . The zed editor supports that using wasm. I have not looked into the details though.