How does Scala3’s multi-stage programming compare to LMS (https://scala-lms.github.io/)?
Well, it seems to me that multi-stage programming is better supported. The core of LMS hasn’t been updated since 2018, and as far as I’m aware, there hasn’t been any artifacts of it published to maven central.
That being said, I never used LMS, so I can’t give you a full comparison between the two. What I can say is that multi-stage programming is rather easy to get going. It uses a lot of the same conventions as typical scala 3 macros, but there exists restrictions that don’t exist in typical macros. That being said, you’re free with multi-stage programming to emit code based on runtime data, which you’re definitely not able to do with standard macros. Finally, multi-stage programming can be expensive. You’re running a scala compiler in your program with it, and the end result of that is that emitting code can take a while. In order to see massive speed improvements from emitted code, you’ll end up writing two copies of your code: A version that doesn’t use runtime information, and an optimized version based on runtime information. You’ll need to swap the implementations out, and use a background thread to compile the optimized version so that the program can keep running while the optimization is taking place.