gluon-lang / gluon

A static, type inferred and embeddable language written in Rust.
https://gluon-lang.org
MIT License
3.16k stars 145 forks source link

Incremental compilation / linking? #936

Open Boscop opened 1 year ago

Boscop commented 1 year ago

Thanks for all your work on Gluon, it seems like the most well-designed embeddable scripting language for Rust hosts :) My use case (procedural music composition / live scripting) requires a fast edit->compile->run cycle (low latency) (which is why I abandoned my previous approach of using Rust for scripting via auto-recompilation & DLL auto-reloading). I'm interested in using Gluon for this use case, so I'm wondering how I can reduce the latency of the edit->compile->run cycle to be as low as possible. Most scripts consists of a few imports from std plus a few imports of user-written modules. E.g. the main module imports std and foo (where foo imports bar). If the user only edits the main file and saves that, it should not recompile std nor foo nor bar, only main. The other modules should only be linked. If the user then edits bar, it would only recompile bar and foo and main but not std.

How can this be done? :)

And what kind of latency can be expected as modules grow large (many symbols)?


(Another alternative I considered was using Haskell instead of Gluon because most of potential users already know Haskell, but with Haskell/curryrs the latency of the edit->compile->run cycle would probably be higher?)

Marwes commented 1 year ago

Salsa is used internally which will ensure that only modules that are changed (and any modules that depend on changed modules, recursively) will recompile between each run. Assuming you keep the salsa database alive that is (it is stored in the gluon thread, and shared to all child threads).

Word of warning though, I have not worked on gluon for a long time and I have no plans to pick it up again. There are still things I'd like to do with it, I just have other interests now.