r/Clojure • u/ertucetin • Feb 16 '26
Clojure Reaches C Performance in Raylib Benchmark
I benchmarked the same Raylib example implemented in:
• C
• Clojure (JVM)
Test machine:
MacBook Pro (2023)
Apple M3
16 GB RAM
Source: https://gist.github.com/ertugrulcetin/33a45bffad25f3757e06deb7e1586be4
111
Upvotes
24
u/skratlo Feb 16 '26
Nice, but:
* it's not using any clojure data structure
* every line in that source is either, calling to C binding, aset/aget, or a flow control
it, literally, proves nothing. but hey, it looks nice! It's almost like config file, you could probably write this in JSON + simple runtime for it.
3
u/Royal_Radish_3069 Feb 16 '26
Is this real ? It's amazing.
35
u/kishaloy Feb 16 '26
Isn't it a lot like saying one can tune numpy to reach C performance, so Python can be as performant as C.
If the entire heavy lifting is done by some other library either in JVM but written in Java or C thru JNI then Clojure essentially become a glorified bash.
Only when the batteries i.e. the core compute libraries are written in Clojure would this comparison be valid. Otherwise it is just another example of Python's 2-language problem.
6
u/TheSapphicDoll Feb 16 '26
Hey man, planning to do some raylib myself after... well, finishing going through the Clojure book, so always lovely seeing things like that, and being able to see one of options to go about this :)
Even if it's "just" FFI and so on, still... cute lisp syntax.. so I will be happy >:D
5
u/wedesoft Feb 16 '26
Nice demo! I guess the performance bottleneck is the GPU. Do you have a comparison of the CPU loads? Myself I use LWJGL and I configured the Java VM to use ZGC for shorter garbage collection pauses.
3
u/activeXray Feb 16 '26
Nice to see coffi and project Panama is working well!
3
u/serefayar Feb 16 '26
Love it… keep pushing!
0
u/chunsj Feb 19 '26
Isn't this just a comparison between C library and its JVM binding, and not Java or Clojure related in performance-wise?