Hi everyone,
I got some free time and started working on something that has been on my back burner forever. Here’s my attempt to replace the Guile-1.8 scheme engine behind the official TeXmacs with Chez Scheme – a compiler that generates highly performant machine code. This effort was started by @mgubi some years back.
Source is below:
Some short notes on implementation off the top of my head:
- Instead of an interpreter, we compile every scheme files first. So the build workflow becomes: build C++ sources first, then bootstraps a headless bare minimal TeXmacs and starts compiling TeXmacs scheme sources.
- The Guile-1.8 code is 20+ years old. And it’s not meant to be compiled by Chez R6RS standard. The high level idea for compilation is to translate (compile) the Guile code into R6RS compliant scheme – mostly just partitioning the run-time code from compile-time code and making some macro helper functions available in the compilation environment. There are some other limitations from chez scheme compilers. All addressed by the compile script (I hope); at least enough for it to compile most sources.
- The compile time for scheme is around 8 mins on my machine. And the incremental build system is currently broken – since I still haven’t figured out a way to pinpoint module dependencies accurately due to TeXmacs’s dynamic executation nature (so no parallel compilation either).
- Performance seems fine. Basic editing works. Though there are bound to be a lot of bugs to fix. At least all plugins are not working. Regarding performance, there’s definitely a lot more we can do with Chez: increasing the optimization level, in-house profiler of chez and packaging all compiled binaries into a texmacs.boot. If done right, we might even skip all the lazy loading.
- While I try to make very little changes to the scheme source code, there are still some necessary changes made to make it work. The hope is that I preserve the semantics and logics when doing this. Definitely need some more experienced eyes to check this.
- This work is aided heavily by LLM. So there are still some under-reviewed code in there. Left for refactoring in the future.
Hope to hear some feedbacks and gauge interests! Also use this with caution and back up you .tm files!