4 ms·
> I had trouble finding benchmarks for Clojure vs. Common Lisp, but Clojure is basically just Java at runtime, so this[^3] will do. If only it were that simple
by medo-bear 3y ago
> I had trouble finding benchmarks for Clojure vs. Common Lisp, but Clojure is basically just Java at runtime, so this[^3] will do.
If only it were that simple ! Clojure has no provision for compile time type checks, unlike Common Lisp running in SBCL. On the other hand Common Lisp running on JVM (see Armed Bear Common Lisp) could theoretically achieve those results because, but if we are including calls to host systems then Embedable CL could better it since it runs on top of C. The optimized Java in the benchmarks you quote in fact looks more like C or Cpp code. Im not informed enough to make a judgement if idiomatic Java even looks like that. Idiomatic SBCL (as opposed to just idiomatic Common Lisp) code does look like the versions achieving best results, because people often use SBCL for compiler optimization
> The benchmarks I could find had Java beating SBCL on most benchmarks,
Most of the benchmarks are actually quite similar - ie within the margin of error. Most of the times when Java did beat SBCL by a somewhat more significant margin I noticed that Java's submission used multi-threading whereas that particular submission for SBCL didn't, so the difference isn't so much as Java vs SBCL, but algorithm a vs algorithm b.
Also, as far as I can remember, it is worth mentioning that there was some controversy over some SBCL submissions. One of the submitters had solutions which saw SBCL beating C, Cpp, Zig, and Rust on some of the numerically intensive benchmarks, however their submissions were rejected later for using a SIMD library which at the time was not yet part of SBCL, but now it is.
- medo-bear 3y agoSee this for reference on SBCL beating C, Fortran, Rust, etc. https://www.reddit.com/r/Common_Lisp/comments/riedio/quite_amazing_sbcl_benchmark_speed_with_sbsimd/ https://www.reddit.com/r/Common_Lisp/comments/riedio/quite_a...
- igouy 3y agoSIMD "beating C, Fortran, Rust, etc." :-)
- medo-bear 3y agoSIMD call in SBCL is explicit, which I personally like. In NumPy, as a counter example, it just happens. It is just a method of talking to the processor to take advantage of parallelization. Java will also have it soon: https://download.java.net/java/early_access/loom/docs/api/jdk.incubator.vector/jdk/incubator/vector/Vector.html https://download.java.net/java/early_access/loom/docs/api/jd...
- igouy 3y agoDoes that comparison show hand-coded SIMD in Fortran? (That comparison no longer seems to show Lisp?)
- medo-bear 3y agoI guess so. Most of the languages compilers use SIMD under the hood -ie implicitly. See https://stackoverflow.com/questions/1516622/what-does-vectorization-mean https://stackoverflow.com/questions/1516622/what-does-vector...
- packetlost 3y agoYeah, I only referenced them as a rough approximation to see the order of magnitude of difference. In my super-rough-math™ I gave SBCL like a 20% performance improvement over Java. Maybe that wasn't sufficient because of runtime type-checking. Unoptmized Java looks pretty similar to C/C++, so optimized Java looking similar doesn't surprise me.
- igouy 3y agoidiomatic Java ? https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/mandelbrot-java-4.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/... idiomatic SBCL ? https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/mandelbrot-sbcl-1.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- medo-bear 3y agoSince my point is that you can use SBCL as compiler optimizer, yes. But this does not mean that I think that solution is a particularly good one, even if it is fast.