I never ever saw anyone doing it for desktop or server applications.
You can manually remove dependencies or.. I think in the Android world you specify what classes can be reflected on and then strip unused code with Proguard (though I could never get it working with Clojure)
Would love to be corrected if I got any of it wrong
On Java's case, all AOT toolchains and embedded deployment workflows have supported similar capabilities.
I’m pretty sure that’s exactly what the Google Closure Compiler does: https://developers.google.com/closure/compiler/docs/limitati...
Though it has a ton of restrictions on how you write code and how you can use reflection.
Like JavaScript?
If you are limiting tooling to subsets, you can also compile subsets of Python or Javascript to machine code.
Even C++ you mention does that - you have explicit __attribute__ calls to avoid linker from dropping code you want to keep for reflection purposes.