r/Clojure • u/alexdmiller • Mar 04 '21
Clojure 1.10.3 release
https://clojure.org/news/2021/03/04/clojure1-10-31
u/lgstein Mar 04 '21
I'm surprised that compiled byte code is now backwards compatible. Was that ever the case?
7
1
u/Bob_la_tige Mar 05 '21
What does that mean ?
16
u/alexdmiller Mar 05 '21 edited Mar 06 '21
I'm not sure exactly what the OP meant - in truth this is somewhat complicated and subtle. When talking about compiled Clojure code, you need to consider the Clojure version at time of compile, the Clojure version at runtime, and the Java version at runtime.
(The Clojure compiler version determines the Java bytecode version which is actually independent of the Java version used at compile time. Clojure up to 1.9 was compiled to Java 1.5 bytecode. Clojure 1.10+ is compiled to Java 1.8 bytecode. The Java at runtime must be >= to the version it was compiled with, but this is generally always true as 1.8 is pretty old now, so you can somewhat ignore the Java side of things.)
In general, Clojure tries very hard to guarantee that Clojure code that compiles on one version will continue to work at runtime on a NEWER version of Clojure. In general, this means we don't ever remove anything that compiled Clojure code may depend on (methods in Compiler, RT, Java classes, etc). Ok to add new stuff or do other more subtle changes allowed by Java bytecode compatibility rules.
The more subtle case at play here is... if I compile some code that uses Clojure core, can I use that compiled code with an OLDER version of the Clojure runtime? The answer is generally, yes if you are not using features that have been added since the runtime version. The patch rolled back above was in the clojure.core/case macro which emitted a call to a new var, which won't exist on an older version. So code compiled with Clojure 1.10.2 that used case would not run if using Clojure < 1.10.2 at runtime. We should not have done that (and I've audited all changes back several releases to ensure we didn't do that somewhere else). Note there are several preconditions to even see this problem - AOT compiling, running that compiled code on an older runtime, and using case. But it's a potential problem that there is just no reason to take on.
15
u/alexdmiller Mar 04 '21
Clojure 1.10.3 is now available
Reverted CLJ-2564 "Improve error message for case" (1.10.2) due to backward compatibility issues
CLJ-2453 Enable reader conditionals in Clojure prepl (thanks Oliver Caldwell for the patch!)