Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clojurescript very slow on compiling

I am trying clojurescript and find it takes a long time to compile a very simple clojurescript source file into js. I can't believe this.

time cljsc hello.cljs '{:optimizations :advanced}' > hello.js

real    1m27.324s
user    1m2.412s
sys     0m0.676s

The snippet is from Clojurescript's github quick start page:

(ns hello)
(defn ^:export greet [n]
  (str "Hello " n))

Leaving out the :optimizations option, I still find it takes a long time:

time cljsc hello.cljs > hello.js

real    0m10.867s
user    0m22.301s
sys 0m0.412s

Is that normal ? Or how can I speed up that ?

like image 354
Boris Avatar asked May 08 '26 21:05

Boris


1 Answers

By calling cljsc you are firing up a JVM every single time you compile, which has to load tons of code, and then do the actual compiling. The JVM startup time alone is painful.

The general workflow is to not use cljsc, but keep a JVM open and compile with it every time. A common way to do this is to use lein-cljsbuild, which I highly recommend.

like image 199
Rayne Avatar answered May 10 '26 23:05

Rayne



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!