r/Clojure • • Jun 24 '26

Clojure Deref (Jun 23, 2026)

28 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/nstgc Jun 25 '26 edited Jun 25 '26

once I had a design I liked I rewrote it using OjAlgo and got comparable performance and it was all on the JVM.

Interesting! Did you write it in Java or use a Clojure wrapper?

edit: Oh, and as for performance, I just remembered that Julia uses BLAS under the hood, so I imagine Neanderthal has similar performance characteristics.

2

u/geokon Jun 26 '26

I wrote the code with Neanderthal, then I refactored the interface to a Protocol. Then I had it set up so there are two "backends" that implement the protocol. The OjAlgo one just does Java interop calls

Julia uses BLAS under the hood

I haven't used Julia, but MATLAB has a similar setup. It generally abstracts most of things away and allows you to just write textbook-like code. I think it has some cleverness in the back to make the outputs optimal.. but it's also very possible to write very slow or very numerically unstable code. With straight BLAS/Neanderthal there is less handholding and lots seemingly basic operations are just not in the API.

Like a basic example, there is no function to make an identity matrix. (I think you're expected to make a diagonal matrix and feed in a series of 1's)