5 ms·
A very important caveat: Clojure compilation is not side-effect free. If you are generating the JVM equivalent of a binary (excluding the assumption of stuff li
by sansnomme 7y ago
A very important caveat: Clojure compilation is not side-effect free. If you are generating the JVM equivalent of a binary (excluding the assumption of stuff like GraalVM) i.e. a überjar, you are going to have a bad day if your code does stuff like edit configuration files, call a JSON API etc. The code would run during the compilation stage. Something to take note of.
- dimitar 7y agoWhat I did with my first clojure web app is simply leave (main) at the end of the file. This would cause an error telling me that a port is unavailable. But still Clojure is a lot of fun and that's something you want to look for in a language.
- deleted 7y ago[deleted]
- fulafel 7y agoI find this comment puzzling, since uberjars are the normal deployment model of Clojure apps and they work well. Are you referring to a situation where you are developing macros and end up doing something at compile time that should happen at runtime? Or maybe a situation where you put your application logic in statements outside function definitions, possibly copied from a REPL session?
- comma_at 7y agoThat's false, building an uberjar has nothing to do wit that. If you're packaging an application typically your -main needs to be AOT compiled, that's why you put :gen-class in your ns declaration. That namespace will get AOT compiled. This still doesn't pose any issues since you shouldn't be doing such side effects in the toplevel. So (alter-config-file!) is bad because that code will run during compilation, but in (defn -main [& args] (alter-config-file!) (app!)) it will run only after calling -main.
- deleted 7y ago[deleted]
- sansnomme 7y agoEvaluation != Compilation that outputs a binary. This is what happens when language authors become overly obsessed with the elegance of SICP and completely forget how to slay dragons, properly.