4 ms·
Random question: Can ClojureScript be compiled in the browser? I only looked at it when it first came out and at that time the ClojureScript compiler only ran v
by benjaminjackman 5y ago
Random question: Can ClojureScript be compiled in the browser? I only looked at it when it first came out and at that time the ClojureScript compiler only ran via the JVM.
- chrisoakman 5y agoClojureScript is self-hosted and thus can be compiled in a browser (see https://clojurescript.io/ https://clojurescript.io/ for an example). For most serious usage and projects you will want to use the JVM though.
- kolme 5y agoYes, with caveats: https://clojurescript.org/guides/self-hosting https://clojurescript.org/guides/self-hosting
- diggan 5y agoI think ClojureScript has been able to compile itself since ~2015 if I remember correctly. There is some helper libraries that makes the experience nicer nowadays too, tools like KLIPSE (https://github.com/viebel/klipse https://github.com/viebel/klipse) Here are some starting points: - https://clojurescript.org/guides/self-hosting https://clojurescript.org/guides/self-hosting - https://practicalli.github.io/clojurescript/quickstart/self-hosted-clojurescript.html https://practicalli.github.io/clojurescript/quickstart/self-... - https://blog.klipse.tech/clojurescript/2016/04/04/self-host-part-1.html https://blog.klipse.tech/clojurescript/2016/04/04/self-host-...
- deleted 5y ago[deleted]
- escherize 5y agoThere is a new thing, and it's kind of a toy [0]. But it lets you load clojurescript from a script tag, so there is practically no setup needed!! [0] - https://borkdude.github.io/sci-script-tag/index.html https://borkdude.github.io/sci-script-tag/index.html
- diggan 5y agoWorth keeping in mind that that's Small Clojure Interpreter (SCI) which while very cool, isn't ClojureScript. Seems to be running Reagent perfectly fine though, so not sure what the exact differences are, AFAIK, SCI is a subset of Clojure.
- stingraycharles 5y agoWow sci can run reagent out of the box? That’s not a small feat, excellent work @borkdude!
- divs1210 5y agoYes. ClojureScript is self-hosting, and there are helper tools out there like klipse that make it easier to set up. A more lightweight option is borkdude's SCI (Small Clojure Interpreter) running inside HTML script tags: https://github.com/borkdude/sci-script-tag https://github.com/borkdude/sci-script-tag
- lmilcin 5y agoWhen I work on ClojureScript app I am actually modifying application that is running in the browser, without ever reloading the page. That would not be possible if it could not compile or at least interpret it in the browser.
- kccqzy 5y agoHot reload doesn't imply compilation in the browser. For all you know lein could be recompiling via the JVM and sending updated JS files to the browser.
- benjaminjackman 5y agoThat sounds pretty cool, is there a guide to setting that up?
- lmilcin 5y agoSure. I use fighwheel. https://figwheel.org/ https://figwheel.org/ Actually, when I develop with clojure, I typically have both backend and frontend running at the same time and I am concurrently modifying both applications without restarting them. This is way, way more convenient than having to restart application and then to bring it to a state to run your test. This is youtube video from which I learned about fighwheel: https://www.youtube.com/watch?v=j-kj2qwJa_E https://www.youtube.com/watch?v=j-kj2qwJa_E Have fun!