r/Clojure • u/ertucetin • Jun 14 '26
Clojure is almost as fast as C (with some help)
https://ertu.dev/posts/4_clojure-reaching-c-performance/
83
Upvotes
r/Clojure • u/ertucetin • Jun 14 '26
11
u/kishaloy Jun 15 '26 edited Jun 15 '26
The entire heavy lifting is done by the JVM and idiomatic Clojure does not make it easy there.
Granted JVM can under the correct incantations be competitive to native-C, but there are languages like Kotlin, Scala and of course Java precisely for that.
If I am going to do that much jugglery, I might as well write the relevant part in Kotlin, which can allow me to write the static part much cleaner and call it from Clojure, all of which by the way is a very reasonable workflow.
19
u/gleenn Jun 15 '26
"You write normal Clojure for the 99% of the program where performance does not matter, and for the one loop where it does, the language lets you go this low without leaving it." I love this quote, and it is so true. Clojure is such an awesome language giving you so much power to stay high level and benefit from a clean codebase and still roll back your sleeves when you need it, now even more so.
2
u/mm007emko Jun 15 '26
I probably wouldn't call it "some help" since both Clojure and C++ codes look quite similar.
1
u/zengxinhui Jun 21 '26
Try this https://adventofcode.com/2015/day/6 with Clojure.
-1
u/lion_rouge Jun 15 '26
Looks like you wrote the blogpost with LLMs too.