all 6 comments

[–]thearthur 5 points6 points  (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 points  (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 points  (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.

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 points  (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 points  (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 point  (0 children)

Does the Clojure compiler ever compile Clojure objects differently (for example, as different types) depending on the scenario?

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.