Fork me on GitHub
Joshua S. Grant01:08:44

Are there any performance benchmarks that compare Clojure to other Lisps? Shockingly haven't found any.


I'm not surprised you haven't found any (or were you being sarcastic, perhaps?).

Joshua S. Grant01:08:31

Nope, legitimately; All my google-fu has led me to is a lot of conjecture on places like HN.


I'd be more surprised if you found any performance benchmarks comparing Lisps to other languages. There are benchmarks across multiple implementations of Common Lisp, but they all use the same benchmark suite (written in Lisp).


You'd also really be comparing apples to oranges unless you can find common applications that act as benchmarks between Lisp implementations and other languages -- which I think is why it's hard to find such things.


With mainstream/modern languages, there are quite a few "standard" benchmarks out there that people have implemented in a wide range of languages (and then heavily tuned the code so it's no longer idiomatic, quite often!).

Joshua S. Grant02:08:07

Well there's the classic (and arguably classically flawed) Debian hosted "Benchmark Game" -- but to my knowledge it doesn't have a clojure page anymore (pretty sure it did at somepoint iirc)

Joshua S. Grant02:08:38

But yeah, I agree it's hard to get a fair-enough benchmark between languages (even Lisps) with such a different execution model, immutable / mutable state at it's core, level of abstraction, etc.

Joshua S. Grant02:08:18

Just find it curious I can't seem to find "anything". lol

Joshua S. Grant02:08:03

My (uniformed) intuition would be that SBCL & Clojure a'la the JVM would be within a magnitude or-so of eachother -- but no idea how close / off that intuition may be. lol

Jakub Šťastný02:08:10

Would be interested in numbers too, just out of curiosity.


i've heard sbcl can get seriously fast with types added in. no idea what it would be like to work on a codebase like that though


You can do things like but it will be very specific to the libraries used, and just for that specific problem.

Ben Sless07:08:09

Compare Java to other lisps, those you can find Clojure can be as fast as Java with enough black magic, so that's your upper bound Should be a good enough ballpark

Robert Mitchell14:08:10

SBCL can reach optimized C++ speeds when all the right type declarations are used, though if the C++ compiler is outputting SIMD instructions it’ll probably win by a factor of 4 or more, since I don’t think SBCL supports optimizing code to use those yet. That said, you can also use inline assembly in SBCL (by defining virtual operations, “vop”s), so you can manually utilize SIMD if you want to reach those speeds too. I’m not aware of any way to reach that level of performance on the JVM.


Java 16 provides SIMD support.


clojure that performs as well as java is usually just bad obfuscated java btw, I highly recommend rewriting code in perf bottle necks in java (especially for numerics)

👍 3
Joshua S. Grant23:08:05

Yeah, I guess I'm somefactor asking about "idiomatic Clojure" and not* Java-with-parens lol


1/10th of idiomatic java is a good thing to expect from clojure


that is, 10x the CPU cycles to get the same result


related (this is already off-topic so why not) today I rewrote a clojure utility in c, I gave up on one fancy feature and no longer do command line parsing, and it resulted in a smaller and simpler c program compared to the original clojure lol

👍 3

(it's a ranked preference random video game character chooser for when I'm not sure what character to play next)

Joshua S. Grant00:08:53

That's actually pretty relevant -- in that I want to get into gamedev a bit at somepoint; Well more-aptly learn about how these things work and was loosely planning somefactor of an 'engine' ... and that's kinda a fear of considering Clojure in-that I'm worried it'll be prohibitive

Joshua S. Grant00:08:43

Looks like basically using Clojure as a scripting-language a'la Arcadia on Unity / Godot and/or wrapping JmonkeyEngine is often 'good enough' but trying to implement "everything" (ie: not just game-logic*) in idiomatic Clojure ... basically everything on-top of LWJGL seems like it'd be at best "more of a challenge" and at-worst not-workable

Ben Sless03:08:38

@U051SS2EU this isn't a very apples to apples comparison, though

Ben Sless03:08:26

one implementation uses maps, sorting, laziness, the other is linear and straightforward. If you reimplement the c program in clojure you'll get something new


that's totally true


maybe I should write clojure more like I write c

Ben Sless03:08:15

depends on what you expect it to do and where

Ben Sless03:08:31

C doesn't let you do a lot so you keep it simple. I sometimes see lots of fancy and complicated data transformations in clojure because it's easy to do

Ben Sless04:08:06

Clojure written with performance in mind can still be idiomatic, but looks very different

Ben Sless04:08:16

I try to move as much as possible to compile time. What can't be done there I move to init time. Try to close over unrolled iteration, use transducers, stuff like that

👍 2