9 ms·
clojurescript run in node? is this on the roadmap?
by lennel 12y ago
clojurescript run in node? is this on the roadmap?
- dkersten 12y agoClojureScript already runs on node: https://github.com/clojure/clojurescript/wiki/Quick-Start#running-clojurescript-on-nodejs https://github.com/clojure/clojurescript/wiki/Quick-Start#ru... I think what GP is complaining about is the compilation step, which requires a JVM and isn't exactly the fastest. Touche - You don't need project.clj and leiningen and can run a command basically like you're asking for. I'm not sure how much faster it is than using leiningen and cljsbuild, as I haven't tried it: https://github.com/clojure/clojurescript/wiki/Quick-Start#clojurescript-compiler https://github.com/clojure/clojurescript/wiki/Quick-Start#cl...
- lennel 12y agothis is what I was reffering too, the compilation step. It seems very daft for me to loose the closure compiler. I assume lein keeps the jvm hot, if not writing a script to do it should be pretty simple.
- dkersten 12y ago`cljsbuild auto` keeps the jvm hot and rebuilds any time the source changes. You could also use something like Nailgun too, if that is more desirable. When I develop in ClojureScript, I generally avoid rebuilding altogether whenever possible (auto or otherwise) and instead have my editor send changes to the browser REPL. I don't know if you can do this with node too, but it would seem odd if not. This seems to be the preferred approach by most Clojure devs.
- Touche 12y agoYes, but I factor in having to create a folder structure, edit the project.clj file to add my compilation targets, and all of that, it's not "light weight" for something like a small script that just is a single widget. Btw, I ran: time lein cljsbuild once on a project with a minor change (added a line break) and it took 22 seconds.... so this is also what I'm talking about.
- Touche 12y agoYou don't have to run JVM Clojure to run Closure. JVM Clojure is the slow part. Port the ClojureScript compilation to Node and still call Closure.
- lennel 12y agoyou are wrong.The closure compiler is written in java. it is a fact of life that you need the jvm.
- Touche 12y agoYou're misunderstanding me, I know closure is written in Java. But closure is not the slow part. I timed doing lein cljsbuild once and it takes like 22 seconds; that's not Closure. That's Clojure itself. ClojureScript would be much faster, it has virtually none of the slowness that JVM Clojure has.
- lennel 12y agoit sounds to me that the jvm is not kept running and you are paying a startup cost each time. Transpiling a bucket load of any language in a warm jvm will be less than 2-3 seconds, and could easily be done on page refresh. to give you some perspective, we have massive closure apps, first compilation on my (very powerful) desktop takes a minute 30 seconds or so (advanced optimizations and several other extremely stringent flags along with quite a few compiler plugins we wrote) keeping the jvm warm, and compiling with these same flags + plugins, the time comes down to under 5 seconds.
- Touche 12y agoJVM startup time is slower than a lot of VMs, but it's not that slow. Write a hello world in Java and see how long it takes, I'd guess 100ms or so. Do the same in Clojure and you're looking at 3-4 seconds. This is a good analysis of why Clojure startup is slow: http://nicholaskariniemi.github.io/2014/02/25/clojure-bootstrapping.html http://nicholaskariniemi.github.io/2014/02/25/clojure-bootst... This is why I think ClojureScript/Node should become the "default" environment for writing Clojure. It would open up Clojure to a new class of apps that are currently not practical.