clojure-site
clojure-site copied to clipboard
Add guidance on when to use AOT compilation
There is a good reference on AOT compilation, but I don't see strong guidance on when to use it, or more specifically when to not use it.
My understanding is that it is relatively safe to employ AOT compilation for an app.
But sometimes a library author will naively use AOT compilation when creating their release jar without realizing the problems this can cause for users of their library. These problems include (additions and corrections most welcome):
- aot compilation will create class files for library dependencies, this effectively brings in these dependencies (or portions of dependencies) at jar creation time, rather than runtime. A user might bring in different versions of those dependencies. Having multiple instances of a dependency on the classpath at runtime leads to confusion.
- a class file will not include metadata such as original clojure filename and line number.
- different versions of Clojure can generate different bytecode
I suppose a note on how/when to safely employ AOT compilation for a lib might also be helpful.