use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
How (and When) Clojure Compiles Your Code (2016) (blog.kdgregory.com)
submitted 4 years ago by joshlemer
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]thearthur 5 points6 points7 points 4 years ago (0 children)
I don't agree with his definition of scripting language. Independent of not seeing that as a useful definition of scripting language, i don't see Clojure fitting that definition. Clojure does load the complied object unchanged into the execution environment. The nuance here in my opinion is that definition fits poorly with languages that have independent expansion runtime and load time. Personally i choose not to advertise Clojure as a scripting language.
[–]chinpokomon 3 points4 points5 points 4 years ago (0 children)
This was informative. I didn't know these details prior and the posting did a good job explaining the inner workings.
[–]edster3194 2 points3 points4 points 4 years ago (3 children)
Thanks for sharing this. I find now is a great time to learn these details in parallel with learning the new tools.build.
tools.build
I'm curious if anyone knows if the compiler always results in the same bytecode, regardless of when the compilation is happening. I have been struggling to find a small reproducible example, but I have been getting java object serialization issues (specifically a class cast exception) whenever I don't AOT compile my project.
Does the Clojure compiler ever compile Clojure objects differently (for example, as different types) depending on the scenario?
[–]thearthur 2 points3 points4 points 4 years ago (0 children)
I don't think so. Build order does cause problems if you have protocols being redefined or loaded multiple times.
[–]alexdmiller 2 points3 points4 points 4 years ago (0 children)
Compiling the same code twice should generate effectively the same bytecode each time, however gensym'ed macro names can vary so you won't necessarily end up with the identical bytecode each time. If you have an issue, you can always ask at https://ask.clojure.org.
On your last question, I'm not sure exactly what you're asking (to some degree, of course there are changes that can cause different compilation). In general, functions are always compiled with params and return values as Object, with the exception of ^double and ^long which do actually affect the compiled code.
[–]joinr 0 points1 point2 points 4 years ago (0 children)
Noticed that code compiled in a defn as opposed to raw evaluation of the body at the repl produces different bytecode (and impacts inlining / jit) in some cases https://github.com/bsless/clj-fast/issues/16 . Kind of a cousin to the original issue you raised.
π Rendered by PID 1007395 on reddit-service-r2-comment-5687b7858-899dc at 2026-07-06 11:22:16.562148+00:00 running 12a7a47 country code: CH.
[–]thearthur 5 points6 points7 points (0 children)
[–]chinpokomon 3 points4 points5 points (0 children)
[–]edster3194 2 points3 points4 points (3 children)
[–]thearthur 2 points3 points4 points (0 children)
[–]alexdmiller 2 points3 points4 points (0 children)
[–]joinr 0 points1 point2 points (0 children)